home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / dtp / textread / source / textread_1.14.s < prev    next >
Encoding:
Text File  |  1996-07-16  |  174.9 KB  |  10,726 lines

  1. *** ScR ***
  2.  
  3. final    =0
  4. setnamelen        =256
  5. release            =113
  6. releasestr    MACRO
  7.         dc.b    "1.14"
  8.         ENDM
  9. version            =38
  10. revision        =84
  11. date        MACRO
  12.         dc.b    "27.1.96"
  13.         ENDM
  14.     
  15. versionstr    MACRO
  16.         dc.b    version/10+'0',(version-version/10*10)+'0'
  17.         ENDM
  18. revisionstr    MACRO
  19.         dc.b    revision/10+'0',(revision-revision/10*10)+'0'
  20.         ENDM
  21.  
  22. maxdepth    =3
  23.  
  24. ;Added the 'Check fonts?' switch.
  25.  
  26. ;Fixed a bug in the search highlight routine (highligt was one pixel off to
  27. ;the right).
  28.  
  29. ;Fixed a bug in system legal print routines, showing up when a file only was
  30. ;one line.
  31.  
  32. ;Textread's screen can now be in either 4 or 8 colours. Added to support some
  33. ;system patches that modifies the look of gadtools gadgets.
  34.  
  35.  
  36.     ifeq    final-1
  37.     PRINTT    "Final version...  :-)"
  38.     auto    wo OT:Textread\
  39.     endif
  40.  
  41.     incdir    include:
  42.     include    exec/funcdef.i
  43.     include    devices/printer.i
  44.     include    devices/prtbase.i
  45.     include    dos/datetime.i
  46.     include    dos/dos.i
  47.     include    lvo/dos_lib.i
  48.     include    dos/dosextens.i
  49.     include    dos/dostags.i
  50.     include    exec/alerts.i
  51.     include    exec/exec.i
  52.     include    lvo/exec_lib.i
  53.     include    graphics/rastport.i
  54.     include    lvo/graphics_lib.i
  55.     include    graphics/gfxbase.i
  56.     include    graphics/displayinfo.i
  57.     include    intuition/gadgetclass.i
  58.     include    intuition/preferences.i
  59.     include    intuition/intuition.i
  60.     include    lvo/intuition_lib.i
  61.     include    libraries/asl.i
  62.     include    lvo/asl_lib.i
  63.     include    lvo/diskfont_lib.i
  64.     include    libraries/gadtools.i
  65.     include    lvo/gadtools_lib.i
  66.     include    utility/utility.i
  67.     include    lvo/utility_lib.i
  68.     include    utility/tagitem.i
  69.     include    workbench/workbench.i
  70.     include lvo/wb_lib.i
  71.     include lvo/icon_lib.i
  72.     include workbench/startup.i
  73.  
  74. ;NM_COMMANDSTRING        EQU     COMMSEQ
  75. ;GTMN_NewLookMenus    EQU    GT_TagBase+67
  76. ;GTLV_MakeVisible    EQU    GT_TagBase+78    ; Make this item visible
  77. ;WA_NewLookMenus        EQU    $80000093
  78. ;WA_BusyPointer        EQU    WA_MenuHelp+6
  79. ;SA_MinimizeISG        EQU    $80000049
  80. ;BMA_FLAGS        EQU    12
  81. ;BMF_STANDARD        EQU    8
  82.  
  83. ;_LVOSetWindowPointerA    EQU    -$330
  84. ;_LVOLoadRGB32        EQU    -882
  85. ;_LVOGetRGB32        EQU    -900
  86. ;_LVOGetUniqueID        EQU    -270
  87. ;_LVOGetBitMapAttr    EQU    -960
  88.  
  89.     include    libraries/ppbase.i
  90.     include    lvo/powerpacker_lib.i
  91.     include    libraries/xpk.i
  92.  
  93.     incdir    include:
  94.     include    hardware/custom.i
  95.     include    hardware/intbits.i
  96.     include    macros.i
  97.  
  98. Message    MACRO
  99.     base    intui
  100.     move.l    windowptr(pc),a0
  101.     move.l    #-1,a1
  102.     lea    \1,a2
  103.     call    SetWindowTitles
  104.     ENDM
  105. wm    macro
  106.     btst    #6,$bfe001
  107.     bne.s    *-8
  108.     btst    #6,$bfe001
  109.     beq.s    *-8
  110.     endm
  111. fl    macro
  112.     move.w    #$ffff,d0
  113.     move.w    d0,$dff180
  114.     dbf    d0,*-6
  115.     endm
  116.  
  117.  STRUCTURE cm,MN_SIZE
  118.    UWORD   cm_command
  119.    ULONG   cm_data
  120.    LABEL   cm_SIZE
  121.  
  122. cmc_open    =1    ;data: pek till lws: filnamn, setname, tabsize
  123. cmc_opennew    =2    ; -"-
  124. cmc_quit    =3    ;N/A
  125.  
  126. err_exitnow    =-1
  127. err_noscreen    =-2
  128. err_nowin    =-3
  129. err_nomenu    =-4
  130. err_nogadget    =-5
  131. err_nofontreq    =-6
  132. err_nofilereq    =-7
  133. err_nomem    =-8
  134. err_nochipmem    =-9
  135. err_nofont    =-10
  136.  
  137.  
  138. ;SHIFTMENU    macro
  139. ;    and.w    #$1F,\1
  140. ;    endm
  141. ;SHIFTITEM    macro
  142. ;    and.w    #$3F,\1
  143. ;    lsl.w    #5,\1
  144. ;    emdm
  145. ;SHIFTSUB    macro
  146. ;    and.w    #$1F,\1
  147. ;    lsl.w    #11,\1
  148. ;    emdm
  149.  
  150. s_exit        =0
  151. TAB        =9
  152.  
  153. start:
  154.         ifeq final-1
  155.     include    startup.i
  156.     move.l    a0,wbmessage
  157.     move.l    d0,boolcli
  158.         endif
  159.     jmp    realstart
  160.  
  161. stayalive:                ;Only exec may be used here!
  162.     base    exec
  163.  
  164.         ifeq final-1
  165.     lea    dosname,a1
  166.     moveq    #0,d0
  167.     call    OpenLibrary
  168.     move.l    d0,a6
  169.     lea    start-4(pc),a0
  170.     move.l    (a0),d1            ;Other segments
  171.     clr.l    (a0)            ;Detach
  172.     call    UnLoadSeg        ;Free
  173.     move.l    a6,a1
  174.     base    exec
  175.     call    CloseLibrary
  176.         endif
  177.  
  178.     move.l    comport(pc),a0
  179.     call    WaitPort
  180. .getallcommsgs
  181.     move.l    comport(pc),a0
  182.     call    GetMsg
  183.     tst.l    d0
  184.     beq.w    .lastmess
  185.     move.l    d0,a1
  186.     move.w    cm_command(a1),d2
  187.     call    ReplyMsg
  188.     cmp.w    #cmc_quit,d2
  189.     beq.b    terminate
  190.     bra.s    .getallcommsgs
  191. .lastmess
  192.  
  193. terminate:
  194.     base    exec
  195.     move.l    commessage(pc),d0
  196.     move.l    d0,a1
  197.     beq.b    .nocommessage
  198.     moveq    #cm_SIZE,d0
  199.     call    FreeMem
  200. .nocommessage
  201.     tst.w    comportispublic
  202.     beq.b    .comnotadded
  203.     move.l    comport(pc),d0
  204.     move.l    d0,a1
  205.     beq.b    .nocomport
  206.     call    RemPort
  207. .comnotadded
  208.     move.l    comport(pc),d0
  209.     move.l    d0,a0
  210.     beq.b    .nocomport
  211.     call    DeleteMsgPort
  212. .nocomport
  213.  
  214.     moveq    #0,d0
  215.     rts
  216.  
  217.  
  218. comport:    dc.l    0
  219. commessage:    dc.l    0
  220. comportispublic:dc.w    0
  221.  
  222.         RSRESET
  223. coma_version:    rs.l    1    ;cli/wb
  224. coma_setname:    rs.l    1    ;cli/wb
  225. coma_boolcli:    rs.l    1    ;cli/wb
  226. coma_tabsize:    rs.l    0    ;cli
  227. coma_numargs:    rs.l    1    ;wb
  228. coma_argnames:    rs.l    0    ;cli
  229. coma_arglist:    rs.l    1    ;wb
  230. coma_currdir:    rs.l    1    ;cli, LOCK!
  231. coma_SIZE:    rs.l    0
  232.  
  233.  
  234.     section    realcode,code
  235. realstart:
  236.     jsr    openlibs
  237.     tst.l    d0
  238.     bmi.w    exit_nolibs
  239.  
  240.     jsr    fixwinmenu        ;if not V39+, remove "Esc", "Tab" etc
  241.     jsr    multi_init
  242.     tst.l    d0
  243.     beq    exit
  244.  
  245.         ifeq final-1
  246.     jsr    getargs
  247.     tst.l    d0
  248.     bmi.w    exit_argerr
  249.         endif
  250.  
  251.     base    exec
  252.     call    CreateMsgPort
  253.     lea    comport,a0
  254.     move.l    d0,(a0)
  255.     beq.w    exit
  256.  
  257.     tst.l    argnew
  258.     bne.w    .startnewcopy
  259.  
  260.     base    exec
  261.     moveq    #cm_SIZE,d0
  262.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  263.     call    AllocMem
  264.     lea    commessage,a0
  265.     move.l    d0,(a0)
  266.     beq.w    exit
  267.  
  268.     move.l    commessage,a1
  269.     move.l    comport,MN_REPLYPORT(a1)
  270.     move.w    #cm_SIZE,MN_LENGTH(a1)
  271.     move.w    #cmc_opennew,cm_command(a1)
  272.     lea    com_array,a0
  273.     move.l    a0,cm_data(a1)
  274.  
  275.     suba.l    a1,a1
  276.     call    FindTask
  277.     move.l    d0,a1
  278.  
  279.     lea    com_array,a0
  280.     move.l    #release,coma_version(a0)
  281.     move.l    pr_CurrentDir(a1),coma_currdir(a0)
  282.     move.l    argset(pc),coma_setname(a0)
  283.     move.l    boolcli(pc),coma_boolcli(a0)
  284.     bne.w    .cli
  285.     move.l    wbmessage(pc),a1
  286.     move.l    sm_NumArgs(a1),coma_numargs(a0)
  287.     move.l    sm_ArgList(a1),coma_arglist(a0)
  288.     bra.b    .messageinited
  289. .cli
  290.     move.l    tabsize(pc),coma_tabsize(a0)
  291.     move.l    argnames(pc),coma_argnames(a0)
  292. .messageinited
  293.     base    exec
  294.     call    Forbid
  295.     lea    programname(pc),a1
  296.     call    FindPort
  297.     tst.l    d0
  298.     beq.b    .noprevcomport
  299.  
  300.     move.l    d0,a0
  301.     move.l    commessage,a1
  302.     call    PutMsg
  303.     call    Permit
  304.  
  305.     move.l    comport,a0
  306.     call    WaitPort
  307. .getallcommsgs
  308.     move.l    comport,a0
  309.     call    GetMsg
  310.     tst.l    d0
  311.     bne.s    .getallcommsgs
  312.  
  313.     bsr.w    cleanup
  314.     jmp    stayalive
  315.  
  316. .noprevcomport
  317.     call    Permit
  318.  
  319. .startnewcopy
  320.     move.l    comport,a1
  321.     lea    programname(pc),a0
  322.     move.l    a0,LN_NAME(a1)
  323.     move.b    #1,LN_PRI(a1)
  324.     call    AddPort
  325.     move.w    #1,comportispublic
  326.  
  327.     lea    bufflist(pc),a0
  328.     TSTNODE    a0,a0
  329.     beq.w    exit
  330.     lea    thisbuff(pc),a1
  331.     move.l    a0,(a1)
  332.     bsr    multi_buff2curr
  333.  
  334.     lea    bufflist(pc),a5
  335.     IFEMPTY    a5,.listisempty
  336.     move.l    MLH_HEAD(a5),a5
  337.     bsr    multi_loadrest
  338.     tst.l    d0
  339.     bne.b    exit
  340. .listisempty
  341.  
  342. *** int server
  343.     base    exec
  344.     moveq    #-1,d0
  345.     call    AllocSignal
  346.     lea    intsignal(pc),a0
  347.     move.l    d0,(a0)
  348.     cmp.l    #-1,d0
  349.     beq.w    exit
  350.  
  351.     lea    int,a1
  352.     move.b    #NT_INTERRUPT,LN_TYPE(a1)
  353.     move.b    #5,LN_PRI(a1)
  354.     lea    intname(pc),a0
  355.     move.l    a0,LN_NAME(a1)
  356.     lea    intsignal(pc),a0
  357.     move.l    a0,IS_DATA(a1)
  358.     lea    interruptet(pc),a0
  359.     move.l    a0,IS_CODE(a1)
  360.     moveq    #INTB_VERTB,d0
  361.     call    AddIntServer
  362.  
  363.  
  364.     bsr.w    handlesignals
  365.     bsr    mopenwb
  366.  
  367. *******************************************************************************
  368.  
  369. exit:
  370.     bsr.b    cleanup
  371.     jmp    terminate
  372.  
  373. cleanup:
  374.     base    exec
  375.     move.l    intsignal(pc),d0
  376.     cmp.l    #-1,d0
  377.     beq.b    .nointsignal
  378.     call    FreeSignal
  379.     lea    int,a1
  380.     moveq    #INTB_VERTB,d0
  381.     call    RemIntServer
  382. .nointsignal
  383.  
  384.     bsr    multi_quit
  385.     bsr.w    closeenvironment
  386. exit_argerr:
  387.     base    dos
  388.     move.l    rastruct(pc),d1
  389.     beq.b    .noargs
  390.     call    FreeArgs
  391. .noargs
  392.     lea    pipeused(pc),a0
  393.     tst.b    (a0)
  394.     bne.b    .nopipe
  395.  
  396.     base    dos
  397.     lea    pipename(pc),a0
  398.     move.l    a0,d1
  399.     call    DeleteFile
  400. .nopipe
  401.  
  402. exit_nolibs:
  403.     bsr.w    closelibs
  404.     rts
  405.  
  406. *******************************************************************************
  407.  
  408. handlesignals:
  409.  
  410. ;*** slav!
  411. ;    base    dos
  412. ;    lea    .dostags(pc),a0
  413. ;    move.l    a0,d1
  414. ;    call    CreateNewProc
  415. ;    lea    slave(pc),a0
  416. ;    move.l    d0,(a0)
  417. ;    beq.w    .noslave
  418. .loop
  419.     base    exec
  420.     moveq    #0,d0
  421.     move.l    intsignal(pc),d1
  422.     bset    d1,d0
  423.     call    Wait            ;the intserver signals each vblank..
  424.  
  425.     move.l    windowptr(pc),a0
  426.     move.l    wd_UserPort(a0),a0
  427.     move.b    MP_SIGBIT(a0),d1
  428.     moveq    #0,d0
  429.     bset    d1,d0
  430.     lea    .usersignal(pc),a0
  431.     move.l    d0,(a0)
  432.  
  433.     move.l    comport,a0
  434.     move.b    MP_SIGBIT(a0),d1
  435.     moveq    #0,d0
  436.     bset    d1,d0
  437.     lea    .comsignal(pc),a0
  438.     move.l    d0,(a0)
  439.  
  440.     or.l    .usersignal(pc),d0
  441.     bset    #SIGBREAKB_CTRL_C,d0
  442.  
  443.     lea    .signal(pc),a0
  444.     move.l    d0,(a0)
  445.  
  446.     moveq    #0,d0
  447.     moveq    #0,d1
  448.     call    SetSignal
  449.     and.l    .signal(pc),d0
  450.     beq.s    .scrolla        ;no signals
  451.  
  452.     base    exec
  453.     lea    .signal(pc),a0
  454.     move.l    d0,(a0)
  455.     call    Wait            ;fetch and clear
  456.     lea    .signal(pc),a0
  457.     move.l    d0,(a0)
  458.  
  459.     move.l    .signal(pc),d1
  460.     and.l    .usersignal(pc),d1    ;userport signal?
  461.     beq.B    .nouserport
  462.     bsr.w    handleIDCMP        ;yep
  463.     tst.l    d0
  464.     bmi.b    .exit
  465. .nouserport
  466.     move.l    .signal(pc),d1
  467.     and.l    .comsignal(pc),d1    ;comport signal?
  468.     beq.B    .nocomport
  469.     bsr    handleCOM        ;yep
  470. .nocomport
  471.     move.l    .signal(pc),d1
  472.     and.l    #SIGBREAKF_CTRL_C,d1
  473.     beq.B    .nobreak
  474.     lea    status(pc),a0
  475.     bset    #s_exit,(a0)        ;if ctrl_c from cli, quit!
  476. .nobreak
  477. .scrolla
  478.     move.w    scrolla(pc),d0
  479.     beq.s    .noscroll
  480.     cmp.w    #scrolla_mouse,d0
  481.     bne.s    .dontupdatespeed
  482.     moveq    #0,d0
  483.     move.w    mousey(pc),d0
  484.     mulu.w    #9,d0
  485.     divu.w    pheight+2(pc),d0
  486.     subq.w    #4,d0
  487.     cmp.w    #4,d0
  488.     ble.s    .speedok
  489.     moveq    #4,d0
  490. .speedok
  491.     lea    scrollfart(pc),a0
  492.     move.w    d0,(a0)
  493.     bra.s    .scrollit
  494. .dontupdatespeed
  495.     cmp.w    #scrolla_crsr,d0
  496.     bne.s    .noscroll
  497.     clr.w    scrolla            ;key pressed, clear.
  498. .scrollit
  499.     move.w    scrollfart(pc),d0
  500.     bsr    scrollsmooth
  501. .noscroll
  502.  
  503.     lea    status(pc),a0
  504.     btst    #s_exit,(a0)
  505.     beq.w    .loop
  506.  
  507. .exit
  508.  
  509. ;    lea    slavecmd+slavemessage(pc),a0
  510. ;    move.w    #-1,(a0)        ;tala om att avsluta!
  511. ;    bsr    slavesendmsg
  512. ;.noslave
  513.     rts
  514.  
  515. .signal        dc.l    0
  516. .usersignal    dc.l    0
  517. .comsignal    dc.l    0
  518.  
  519. ;.dostags
  520. ;    dc.l    NP_Entry,slavefunc
  521. ;    dc.l    NP_Name,.slavename
  522. ;    dc.l    TAG_DONE
  523. ;.slavename
  524. ;    dc.b    "Textread slave process",0
  525.  
  526. scrolla_mouse:    equ    1
  527. scrolla_crsr:    equ    2
  528. scrolla:    dc.w    0
  529. scrollfart:    dc.w    0
  530. mousey:        dc.w    0
  531.  
  532. intsignal:    dc.l    -1
  533.  
  534. interruptet:
  535.     base    exec
  536.     move.l    (a1),d1
  537.     moveq    #0,d0
  538.     bset    d1,d0
  539.     move.l    thistask(pc),a1
  540.     call    Signal
  541.     moveq    #0,d0
  542.     rts
  543.  
  544. *******************************************************************************
  545. ********************** C O M  *************************************************
  546. *******************************************************************************
  547. handleCOM:
  548. .loop
  549.     base    exec
  550.     move.l    comport,a0
  551.     call    GetMsg
  552.     tst.l    d0
  553.     beq.w    .exit
  554.     move.l    d0,.mess
  555.     move.l    d0,a0
  556.     cmp.w    #cmc_opennew,cm_command(a0)
  557.     bne.b    .notopennew
  558.     pushm    a0
  559.     bsr    mnew
  560.     popm    a0
  561.     bra.b    .open
  562. .notopennew
  563.     cmp.w    #cmc_open,cm_command(a0)
  564.     bne.b    .notopen
  565. .open
  566.     lea    .array(pc),a1
  567.     move.l    cm_data(a0),(a1)
  568.  
  569.     lea    .thisbuff(pc),a0
  570.     move.l    thisbuff(pc),(a0)
  571.  
  572.     move.l    .array(pc),a0
  573.     cmp.l    #release,coma_version(a0)
  574.     bne.b    .notopen
  575.     move.l    coma_setname(a0),a0
  576.     bsr    loadsettings
  577.     bsr    prefs2curr
  578.     move.l    .array(pc),a0
  579.     tst.l    coma_boolcli(a0)
  580.     bne.b    .cli
  581.     move.l    coma_numargs(a0),d1
  582.     move.l    coma_arglist(a0),a2
  583.     bsr.w    parsewbarg
  584.     bra.b    .open_buffscreated
  585. .cli
  586.     lea    tabsize(pc),a1
  587.     move.l    coma_tabsize(a0),(a1)
  588.     move.l    coma_argnames(a0),a2
  589.     move.l    .array(pc),a0
  590.     move.l    coma_currdir(a0),d0
  591.     bsr.w    parsefilenamearray
  592. .open_buffscreated
  593.     move.l    .thisbuff(pc),a5
  594.     bsr    multi_loadrest
  595.     move.l    .mess(pc),a0
  596.     ;remeber who signalled us, send a quit message when the buffer
  597.     ;is closed later on (multi_freebuff)
  598.     move.l    MN_REPLYPORT(a0),buff_commessageport(a5)
  599. .notopen
  600.     base    exec
  601.     move.l    .mess(pc),a1
  602.     call    ReplyMsg
  603.     bra.w    .loop
  604. .exit
  605.     rts
  606. .mess        dc.l    0
  607. .array        dc.l    0
  608. .thisbuff    dc.l    0
  609.  
  610. *******************************************************************************
  611. ********************** I D C M P **********************************************
  612. *******************************************************************************
  613. handleIDCMP:
  614.     base    gt
  615.     move.l    windowptr(pc),a0
  616.     move.l    wd_UserPort(a0),a0
  617.     call    GT_GetIMsg
  618.     tst.l    d0
  619.     beq.w    .exit
  620.     moveq    #0,d3
  621.     moveq    #0,d4
  622.     moveq    #0,d5
  623.     moveq    #0,d6
  624.     move.l    d0,a0
  625.     move.l    im_IAddress(a0),a2
  626.     move.l    im_Class(a0),d2
  627.     move.w    im_Code(a0),d3
  628.     move.w    im_Qualifier(a0),d4
  629.     move.w    im_MouseX(a0),d5
  630.     move.w    im_MouseY(a0),d6
  631.         movem.l    a0/a6,-(sp)
  632.         lea    mousey(pc),a1
  633.         move.w    d6,(a1)
  634.         cmp.l    #IDCMP_MENUVERIFY,d2
  635.         bne.w    .notmenuverify
  636.         lea    scrolla(pc),a0
  637.         clr.w    (a0)
  638. .notmenuverify
  639.         movem.l    (sp)+,a0/a6
  640.  
  641.     move.l    a0,a1
  642.     call    GT_ReplyIMsg
  643.  
  644.     pea    .return(pc)        ;-<>-
  645.  
  646.     cmp.l    #IDCMP_MENUPICK,d2
  647.     beq.B    menupick
  648.     cmp.l    #IDCMP_RAWKEY,d2
  649.     beq.w    rawkey
  650.     cmp.l    #IDCMP_VANILLAKEY,d2
  651.     beq.w    vanillakey
  652.     cmp.l    #IDCMP_REFRESHWINDOW,d2
  653.     beq.w    refreshwindow
  654.     cmp.l    #IDCMP_MOUSEMOVE,d2
  655.     beq.w    handlegadgets
  656.     cmp.l    #IDCMP_GADGETUP,d2
  657.     beq.w    handlegadgets
  658.     cmp.l    #IDCMP_MOUSEBUTTONS,d2
  659.     beq.w    handlebuttons
  660.     cmp.l    #IDCMP_INACTIVEWINDOW,d2
  661.     bne.w    .notinactive
  662.     lea    scrolla(pc),a0
  663.     clr.w    (a0)
  664. .notinactive
  665.  
  666.     addq.l    #4,sp            ;-<>-    clean up!
  667.  
  668.     bra.w    handleIDCMP
  669. .return
  670.     tst.l    d0
  671.     bne.b    .exit
  672.     bra.w    handleIDCMP
  673. .exit
  674.     rts
  675.  
  676. *********************************************************************** project
  677.  
  678. menupick:
  679. .loop
  680.     base    intui
  681.     moveq    #0,d0
  682.     move.w    d3,d0            ;code=menu number
  683.     move.l    winmenuptr(pc),a0
  684.     call    ItemAddress
  685.     lea    .item(pc),a0
  686.     move.l    d0,(a0)
  687.     move.l    d0,a0
  688.     move.l    d0,a1
  689.     cmp.w    #MENUNULL,d3
  690.     beq.b    .end
  691.     pea    .cont(pc)
  692.     GTMENUITEM_USERDATA    a1,a1
  693.     move.l    a1,d0            ;test!
  694.     beq.b    .end
  695.     jmp    (a1)            ;a0: pointer to menu structure
  696. .end
  697.     moveq    #0,d0
  698. .exit
  699.     rts
  700. .cont
  701.     tst.l    d0
  702.     bne.b    .exit
  703.     move.l    .item(pc),a0
  704.     move.w    mi_NextSelect(a0),d3
  705.     bra.B    .loop
  706. .item    dc.l    0
  707.  
  708. mnew:
  709.     bsr    multi_new
  710.     tst.l    d0
  711.     bne.b    .error
  712.     moveq    #1,d0
  713. .error
  714.     rts
  715. mopen:
  716.     moveq    #FALSE,d0            ;Open!
  717.     bsr.w    askfile
  718.     tst.l    d0
  719.     beq.b    .cancel
  720.     
  721.     bsr.w    openfile
  722. .cancel
  723.     moveq    #0,d0
  724.     rts
  725.  
  726. ;    lea    .thisbuff(pc),a0
  727. ;    move.l    thisbuff(pc),(a0)
  728. ;    move.l    coma_numargs(a0),d1
  729. ;    move.l    coma_arglist(a0),a2
  730. ;    bsr.w    parsewbarg
  731. ;    move.l    .thisbuff(pc),a5
  732. ;    bsr    multi_loadrest
  733.  
  734.  
  735. mopennew:
  736.     bsr    mnew
  737.     cmp.l    #1,d0
  738.     bne.b    .error
  739.     bsr.b    mopen
  740.     moveq    #1,d0
  741. .error
  742.     rts
  743.  
  744. msave:
  745.     lea    savetext(pc),a1
  746.     lea    savegadget(pc),a2
  747.     lea    .args(pc),a4
  748.     bsr    requester
  749.  
  750.     tst.l    d0
  751.     beq.b    .exit
  752.     lea    filereqdir(pc),a0
  753.     lea    filename(pc),a1
  754.     lea    temp,a2
  755.     move.w    #tempsize,d0
  756.     bsr.w    pathnfiletobuff
  757.  
  758.     move.l    #temp,d0
  759.     bsr    savefile
  760. .exit
  761.     moveq    #0,d0
  762.     rts
  763. .args
  764.     dc.l    filename
  765.  
  766. msaveas:
  767.     moveq    #TRUE,d0        ;Save!
  768.     bsr.w    askfile
  769.     tst.l    d0
  770.     beq.b    .cancel
  771.  
  772.     bsr.w    savefile
  773. .cancel
  774.     moveq    #0,d0
  775.     rts
  776. mprint:
  777.     jmp    printfile
  778. mprintas:
  779.     jsr    requestprintopts
  780.     subq.l    #1,d0
  781.     beq.b    mprint
  782.     moveq    #0,d0
  783.     rts
  784.  
  785. mreveal:
  786.     move.l    thisbuff(pc),a0
  787.     bsr    multi_curr2buff        ;update list!
  788.     jsr    requestreveal
  789.     tst.l    d0
  790.     bmi.s    .exit
  791.     beq.s    .cancel
  792.     move.l    bnum(pc),d0
  793.     subq.l    #1,d0
  794.     bsr    multi_change
  795.     bmi.b    .exit            ;can't happen.. (?) :)
  796. .cancel
  797.     moveq    #1,d0
  798. .exit
  799.     rts
  800.  
  801. mclose:
  802.     lea    bufflist(pc),a0
  803.     move.l    MLH_HEAD(a0),d0
  804.     cmp.l    MLH_TAILPRED(a0),d0
  805.     beq.w    mquit            ;quit last time
  806.  
  807.     bsr    multi_close
  808.     tst.l    d0
  809.     bne.b    .exit
  810.     bsr    updatemenu
  811.     moveq    #1,d0
  812. .exit
  813.     rts
  814.  
  815. miconify:
  816.     bsr    mopenwb
  817.     bra.w    iconify
  818.  
  819. mopenwb:
  820.     base    intui
  821.     call    OpenWorkBench
  822.     moveq    #0,d0
  823.     rts
  824.  
  825. mclosewb:
  826.     base    intui
  827.     call    CloseWorkBench
  828.     moveq    #0,d0
  829.     rts
  830.  
  831. mabout:
  832.     lea    .fill(pc),a4
  833.     move.l    filelen(pc),(a4)+
  834.     base    exec
  835.     moveq    #0,d1
  836.     call    AvailMem
  837.     move.l    d0,(a4)+
  838.     move.l    #MEMF_LARGEST,d1
  839.     call    AvailMem
  840.     move.l    d0,(a4)+
  841.     lea    abouttext(pc),a1
  842.     lea    oktext(pc),a2
  843.     lea    .args(pc),a4
  844.     bsr.w    requester
  845.     moveq    #0,d0
  846.     rts
  847. .args    dc.l    .releasestr
  848.     dc.l    .versionstr
  849.     dc.l    filename
  850. .fill    dc.l    0,0,0
  851.  
  852. .releasestr
  853.     releasestr
  854.     dc.b    0
  855. .versionstr    
  856.     versionstr
  857.     dc.b    "."
  858.     revisionstr
  859.     dc.b    0
  860.  
  861.     even
  862. mquit:
  863.     lea    status(pc),a0
  864.     bset    #s_exit,(a0)
  865.     moveq    #1,d0
  866. .exit
  867.     rts
  868.  
  869. ********************************************************************** settings
  870.  
  871. wordwrap:
  872.     dc.w    0
  873. mwordwrap:
  874.     lea    wordwrap(pc),a1
  875.     bsr.w    checkmark
  876.     tst.l    d0
  877.     beq.b    .nochange
  878.     bsr.w    countlines
  879.     tst.l    d0
  880.     bne.b    .exit
  881.     bsr.w    textredraw
  882. .nochange
  883.     moveq    #0,d0
  884. .exit
  885.     rts
  886. sysfont:
  887.     dc.w    0
  888. msysfont:
  889.     lea    sysfont(pc),a1
  890.     bsr.w    checkmark
  891.     tst.l    d0
  892.     beq.b    .nochange
  893.     bsr.w    changevideomode
  894.     tst.l    d0
  895.     bne.b    .exit
  896.     moveq    #1,d0
  897. .exit
  898.     rts
  899. .nochange
  900.     moveq    #0,d0
  901.     rts
  902. alwaysremansi:
  903.     dc.w    0
  904. malwaysremansi:
  905.     lea    alwaysremansi(pc),a1
  906.     bsr.w    checkmark
  907.     moveq    #0,d0
  908.     rts
  909. alwaysremcr:
  910.     dc.w    0
  911. malwaysremcr:
  912.     lea    alwaysremcr(pc),a1
  913.     bsr.w    checkmark
  914.     moveq    #0,d0
  915.     rts
  916. nofontfake:
  917.     dc.w    0
  918. mnofontfake:
  919.     lea    nofontfake(pc),a1
  920.     bsr.w    checkmark
  921.     tst.l    d0
  922.     beq.b    .nochange
  923.     moveq    #TRUE,d0
  924.     bsr.w    fixafonten
  925.     bsr    recountlines
  926.     bsr.w    textredraw
  927. .nochange
  928.     moveq    #0,d0
  929.     rts
  930. legalprint:
  931.     dc.w    0
  932. mlegalprint: 
  933.     lea    legalprint(pc),a1
  934.     bsr.w    checkmark
  935.     tst.l    d0
  936.     beq.b    .nochange
  937.     clr.w    oldfontsize        ;force update of font
  938.     tst.w    (a1)
  939.     beq.b    .fast
  940.     lea    nofontfake(pc),a0
  941.     move.w    #TRUE,(a0)
  942. .fast
  943.     bsr.w    updatemenu
  944.     bsr.w    updatecheckmarks
  945.  
  946.     moveq    #TRUE,d0
  947.     bsr.w    fixafonten
  948.     bsr    recountlines
  949.     bsr.w    textredraw
  950. .nochange
  951.     moveq    #0,d0
  952. .error
  953.     rts
  954. fontcheck:
  955.     dc.w    0
  956. mfontcheck:
  957.     lea    fontcheck(pc),a1
  958.     bsr.w    checkmark
  959.     moveq    #0,d0
  960.     rts
  961. mtabsize:
  962.     jsr    requesttabsize
  963.     tst.l    d0
  964.     bmi.s    .exit
  965.     beq.s    .cancel
  966.     lea    tabbar,a0
  967.     bsr.w    fixatabbar
  968.     bsr.w    countlines
  969.     tst.l    d0
  970.     bne.b    .exit
  971. .ok
  972.     bsr.w    textredraw
  973. .cancel
  974.     moveq    #0,d0
  975. .exit
  976.     rts
  977. ;in:
  978. * a0    pek på (word) strukt: MinX, MinY, MaxX, MaxY
  979. getfontlimits:
  980.     move.l    a0,a1
  981.     moveq    #8,d0
  982.     move.w    d0,(a0)+
  983.     move.w    d0,(a0)+
  984.     move.w    d0,(a0)+
  985.     move.w    d0,(a0)+
  986.  
  987.     lea    legalprint(pc),a0
  988.     tst.w    (a0)
  989.     beq.b    .exit
  990.  
  991.     move.l    pwidth(pc),d0
  992.     divu.w    #254,d0            ;max chars/row
  993.     cmp.w    #5,d0
  994.     bpl.b    .xgt5
  995.     moveq    #5,d0
  996. .xgt5
  997.     move.w    d0,(a1)            ;MinX
  998.  
  999.     move.l    pwidth(pc),d0
  1000.     divu.w    #80,d0            ;min chars/row
  1001.     move.w    d0,4(a1)        ;MaxX
  1002.  
  1003.     move.l    pheight(pc),d0
  1004.     sub.l    barheight(pc),d0
  1005.     sub.l    fonty(pc),d0
  1006.     subq.l    #4,d0            ;space for bevelbox
  1007.     move.l    d0,d1
  1008.  
  1009.     divu.w    #254,d1            ;max rows
  1010.     cmp.w    #5,d1
  1011.     bpl.b    .ygt5
  1012.     moveq    #5,d1
  1013. .ygt5
  1014.     move.w    d1,2(a1)        ;MinY
  1015.  
  1016.     divu.w    #20,d0            ;min rows
  1017.     move.w    d0,6(a1)        ;MaxY
  1018. .exit
  1019.     rts
  1020.  
  1021. mscreen:
  1022.     base    asl
  1023.     cmp.w    #38,LIB_VERSION(a6)
  1024.     bhs.w    .v38
  1025.     lea    smodetext(pc),a1
  1026.     lea    smodegadget(pc),a2
  1027.     suba.l    a4,a4
  1028.     bsr    requester
  1029.     tst.l    d0
  1030.     beq.w    .error
  1031.     move.l    #4,screendepth
  1032.     lea    displayid(pc),a0
  1033.     cmp.w    #1,d0
  1034.     bne.w    .not_pal
  1035.     move.l    #PAL_MONITOR_ID|HIRES_KEY,(a0)
  1036. .not_pal
  1037.     cmp.w    #2,d0
  1038.     bne.w    .not_pal_lace
  1039.     move.l    #PAL_MONITOR_ID|HIRESLACE_KEY,(a0)
  1040. .not_pal_lace
  1041.     cmp.w    #3,d0
  1042.     bne.w    .not_ntsc
  1043.     move.l    #NTSC_MONITOR_ID|HIRES_KEY,(a0)
  1044. .not_ntsc
  1045.     cmp.w    #4,d0
  1046.     bne.w    .not_ntsc_lace
  1047.     move.l    #NTSC_MONITOR_ID|HIRESLACE_KEY,(a0)
  1048. .not_ntsc_lace
  1049.     cmp.w    #5,d0
  1050.     bne.w    .not_vga_prod
  1051.     move.l    #VGA_MONITOR_ID|VGAPRODUCT_KEY,(a0)
  1052. .not_vga_prod
  1053.     bra.w    .changeit
  1054. .v38
  1055.     lea    .tagswin(pc),a0
  1056.     move.l    windowptr(pc),(a0)
  1057.     lea    .tagsdispid(pc),a0
  1058.     move.l    displayid(pc),(a0)
  1059.     lea    .tagsdepth(pc),a0
  1060.     move.l    screendepth(pc),(a0)
  1061.  
  1062.     lea    .scrnreqhgt(pc),a0
  1063.     move.l    pheight(pc),d0
  1064.     mulu    #7,d0
  1065.     lsr.l    #3,d0
  1066.     move.l    d0,(a0)
  1067.  
  1068.     moveq    #ASL_ScreenModeRequest,d0
  1069.     lea    .tags(pc),a0
  1070.     call    AllocAslRequest
  1071.     lea    .screenreq(pc),a0
  1072.     move.l    d0,(a0)
  1073.     beq.w    .error
  1074.  
  1075.     move.l    .screenreq(pc),a0
  1076.     lea    tag_done(pc),a1
  1077.     call    AslRequest
  1078.     tst.l    d0
  1079.     beq.b    .cancel
  1080.  
  1081.     move.l    .screenreq(pc),a0
  1082.     lea    displayid(pc),a1
  1083.     move.l    sm_DisplayID(a0),(a1)
  1084.     lea    screendepth(pc),a1
  1085.     moveq    #0,d0
  1086.     move.w    sm_DisplayDepth(a0),d0
  1087.     move.l    d0,(a1)
  1088.     base    asl
  1089.     move.l    .screenreq(pc),a0
  1090.     call    FreeAslRequest
  1091. .changeit
  1092.     bsr.w    changevideomode
  1093.     tst.l    d0
  1094.     bne.b    .exit
  1095.     moveq    #1,d0            ;process no more menus
  1096. .exit
  1097.     rts
  1098. .cancel
  1099.     base    asl
  1100.     move.l    .screenreq(pc),a0
  1101.     call    FreeAslRequest
  1102. .error
  1103.     moveq    #0,d0
  1104.     rts
  1105. .screenreq
  1106.     dc.l    0
  1107. .tags
  1108.     dc.l    ASLSM_Window
  1109. .tagswin
  1110.     dc.l    0
  1111.     dc.l    ASLSM_SleepWindow,TRUE
  1112.     dc.l    ASLSM_InitialDisplayID
  1113. .tagsdispid
  1114.     dc.l    0
  1115.     dc.l    ASLSM_InitialDisplayDepth
  1116. .tagsdepth
  1117.     dc.l    2
  1118.     dc.l    ASLSM_DoDepth,TRUE
  1119.     dc.l    ASLSM_MinDepth,2
  1120.     dc.l    ASLSM_MaxDepth,maxdepth
  1121.     dc.l    ASLSM_PropertyFlags,DIPF_IS_WB
  1122.     dc.l    ASLSM_PropertyMask,DIPF_IS_WB
  1123.     dc.l    ASLSM_FilterFunc,.hook
  1124.     dc.l    ASLSM_InitialHeight
  1125. .scrnreqhgt
  1126.     dc.l    100
  1127.     dc.l    TAG_DONE
  1128.  
  1129. .entry
  1130.     move.l    h_SubEntry(a0),a0
  1131.     jsr    (a0)
  1132.     rts
  1133. .subentry
  1134.     move.l    a6,-(sp)
  1135.     base    intui
  1136.     move.l    a1,a0            ;displayid
  1137.     lea    temp,a1
  1138.     clr.l    (a1)
  1139.     clr.l    4(a1)            ;just some cleanup
  1140.     moveq    #OSCAN_TEXT,d0
  1141.     call    QueryOverscan
  1142.  
  1143.     lea    temp,a0
  1144.     move.w    ra_MaxX(a0),d0
  1145.     sub.w    ra_MinX(a0),d0
  1146.     cmp.w    #639,d0
  1147.     blo.s    .false
  1148.     move.w    ra_MaxY(a0),d0
  1149.     sub.w    ra_MinY(a0),d0
  1150.     cmp.w    #199,d0
  1151.     blo.s    .false
  1152.  
  1153.     move.l    (sp)+,a6
  1154.     moveq    #TRUE,d0
  1155.     rts
  1156. .false
  1157.     move.l    (sp)+,a6
  1158.     moveq    #FALSE,d0
  1159.     rts
  1160. .hook
  1161.     ds.b    MLN_SIZE
  1162.     dc.l    .entry
  1163.     dc.l    .subentry
  1164.     dc.l    NULL
  1165.  
  1166. mscreencol:
  1167.     bsr    lockwindow
  1168.     base    dos
  1169.     lea    .command(pc),a0
  1170.     move.l    a0,d1
  1171.     lea    .tags(pc),a0
  1172.     move.l    a0,d2
  1173.     call    SystemTagList
  1174.     tst.l    d0
  1175.     beq.b    .exit
  1176.     bsr    unlockwindow
  1177.     lea    colerrortext(pc),a1
  1178.     lea    oktext(pc),a2
  1179.     suba.l    a4,a4
  1180.     bsr    requester
  1181.     bsr    lockwindow
  1182. .exit
  1183.     lea    palette(pc),a1
  1184.     bsr    getpalette
  1185.     bsr    unlockwindow
  1186.     moveq    #0,d0
  1187.     rts
  1188.  
  1189. .command
  1190.     dc.b    "SYS:Tools/Colors",0
  1191.     even
  1192. .tags    
  1193.     dc.l    SYS_UserShell,TRUE
  1194.     dc.l    TAG_DONE
  1195.  
  1196. mdefcol:
  1197.     lea    defpalette,a1
  1198.     bsr    changepalette
  1199.     moveq    #0,d0
  1200.     rts
  1201.  
  1202. mtextfont:
  1203.     lea    .minx(pc),a0
  1204.     bsr    getfontlimits
  1205.  
  1206.     lea    .freqminheight+2(pc),a0
  1207.     move.w    .miny(pc),(a0)
  1208.     lea    .freqmaxheight+2(pc),a0
  1209.     move.w    .maxy(pc),(a0)
  1210.  
  1211.     lea    savedfont,a0
  1212.     lea    savedfontname,a1
  1213.     bsr.w    savefont
  1214.  
  1215.     lea    .freqdefheight(pc),a0
  1216.     move.w    thisfont+ta_YSize(pc),2(a0)
  1217.     lea    .window(pc),a0
  1218.     move.l    windowptr(pc),(a0)
  1219.     lea    .fontreqhgt(pc),a0
  1220.     move.l    pheight(pc),d0
  1221.     mulu    #7,d0
  1222.     lsr.l    #3,d0
  1223.     move.l    d0,(a0)
  1224.  
  1225.     base    asl
  1226.     moveq    #ASL_FontRequest,d0
  1227.     lea    .tags(pc),a0
  1228.     call    AllocAslRequest
  1229.     lea    .fontreqptr(pc),a0
  1230.     move.l    d0,(a0)
  1231.     beq.s    .exit
  1232. .selectagain
  1233.     base    asl
  1234.     move.l    .fontreqptr(pc),a0
  1235.     lea    tag_done(pc),a1
  1236.     call    AslRequest
  1237.     tst.l    d0
  1238.     beq.B    .cancel
  1239.  
  1240.     move.l    .fontreqptr(pc),a0
  1241.     lea    fo_Attr(a0),a0
  1242.  
  1243.     bsr.w    changefont
  1244.     tst.l    d0
  1245.     bne.b    .selectagain
  1246.  
  1247.     move.l    myfont(pc),a1
  1248.  
  1249.     move.w    .miny(pc),d0
  1250.     cmp.w    tf_YSize(a1),d0
  1251.     bhi.b    .selectagain        ;<min?
  1252.     move.w    .maxy(pc),d0
  1253.     cmp.w    tf_YSize(a1),d0
  1254.     blo.b    .selectagain        ;>max?
  1255.  
  1256.     move.w    .minx(pc),d0
  1257.     cmp.w    tf_XSize(a1),d0
  1258.     bhi.b    .selectagain        ;<min?
  1259.     move.w    .maxx(pc),d0
  1260.     cmp.w    tf_XSize(a1),d0
  1261.     blo.b    .selectagain        ;>max?
  1262.     bra.s    .exit
  1263. .cancel
  1264.     lea    savedfont,a0
  1265.     bsr.w    changefont
  1266. .exit
  1267.     base    asl
  1268.     move.l    .fontreqptr(pc),a0
  1269.     clr.l    .fontreqptr
  1270.     call    FreeAslRequest
  1271.  
  1272.     moveq    #FALSE,d0
  1273.     bsr.w    fixafonten
  1274.     bsr    recountlines
  1275.     bsr.w    textredraw
  1276.     moveq    #0,d0
  1277. .error
  1278.     rts
  1279.  
  1280. .minx    dc.w    0
  1281. .miny    dc.w    0
  1282. .maxx    dc.w    0
  1283. .maxy    dc.w    0
  1284.  
  1285. .entry
  1286.     base    diskfont
  1287.     move.l    a6,d0
  1288.     beq.b    .hookrettrue        ;If no diskfont.library, return(1)
  1289.  
  1290.     btst.b    #FPB_PROPORTIONAL,ta_Flags(a1)
  1291.     bne.b    .hookfelfont
  1292.  
  1293.     move.w    .miny(pc),d0
  1294.     cmp.w    ta_YSize(a1),d0
  1295.     bhi.b    .hookfelfont        ;<min?
  1296.     move.w    .maxy(pc),d0
  1297.     cmp.w    ta_YSize(a1),d0
  1298.     blo.b    .hookfelfont        ;>max?
  1299.  
  1300.     tst.w    fontcheck
  1301.     beq.b    .hookrettrue
  1302.  
  1303.     move.l    a1,a0
  1304.     call    OpenDiskFont
  1305.     tst.l    d0
  1306.     beq.b    .hookrettrue        ;If error, return(1)
  1307.     move.l    d0,a0
  1308.  
  1309.     move.w    tf_XSize(a0),d2
  1310.  
  1311.     base    gfx
  1312.     move.l    d0,a1
  1313.     call    CloseFont
  1314.  
  1315.     move.w    .minx(pc),d0
  1316.     cmp.w    d2,d0
  1317.     bhi.b    .hookfelfont        ;<min?
  1318.     move.w    .maxx(pc),d0
  1319.     cmp.w    d2,d0
  1320.     blo.b    .hookfelfont        ;>max?
  1321.  
  1322. .hookrettrue
  1323.     moveq    #TRUE,d0
  1324.     rts
  1325. .hookfelfont
  1326.     moveq    #FALSE,d0
  1327.     rts
  1328. .hook
  1329.     ds.b    MLN_SIZE
  1330.     dc.l    .entry
  1331.     dc.l    NULL
  1332.     dc.l    NULL
  1333. .tags
  1334.     dc.l    ASLFO_Window
  1335. .window    dc.l    0
  1336.     dc.l    ASLFO_SleepWindow,TRUE
  1337.     dc.l    ASLFO_FixedWidthOnly,TRUE
  1338.     dc.l    ASLFO_InitialSize
  1339. .freqdefheight
  1340.     dc.l    8
  1341.     dc.l    ASLFO_InitialName,thisfontname
  1342.     dc.l    ASLFO_MinHeight
  1343. .freqminheight
  1344.     dc.l    8
  1345.     dc.l    ASLFO_MaxHeight
  1346. .freqmaxheight
  1347.     dc.l    8
  1348.     dc.l    ASLFO_FilterFunc,.hook
  1349.     dc.l    ASLFO_InitialHeight
  1350. .fontreqhgt
  1351.     dc.l    100
  1352.     dc.l    TAG_DONE
  1353. .fontreqptr    dc.l    0
  1354.     even
  1355.  
  1356. mdeffont:
  1357.     lea    legalprint(pc),a0
  1358.     tst.w    (a0)
  1359.     bne.b    .legal
  1360.  
  1361.     lea    topaz8font(pc),a0
  1362.     bsr.w    changefont
  1363.     bra.b    .fontok
  1364. .legal
  1365.     lea    deffont,a0
  1366.     bsr.w    changefont
  1367. .fontok
  1368.     moveq    #FALSE,d0
  1369.     bsr.w    fixafonten
  1370.     bsr    recountlines
  1371.     bsr.w    textredraw
  1372.     moveq    #0,d0
  1373. .error
  1374.     rts
  1375.  
  1376. mloadset:
  1377. .again
  1378.     lea    setfreqtitle(pc),a0
  1379.     lea    loadsettitle(pc),a1
  1380.     move.l    a1,(a0)
  1381.     move.l    #FALSE,setfreqsave
  1382.     base    asl
  1383.     move.l    setfreqptr(pc),a0
  1384.     lea    setfreqtags(pc),a1
  1385.     call    AslRequest
  1386.     tst.l    d0
  1387.     beq.s    .error
  1388.  
  1389.     move.l    setfreqptr(pc),a0
  1390.     move.l    fr_File(a0),a1
  1391.     move.l    fr_Drawer(a0),a0
  1392.     lea    temp,a2
  1393.     move.w    #tempsize,d0
  1394.     bsr.w    pathnfiletobuff
  1395.  
  1396.     lea    temp,a0
  1397.     bsr    loadsettings
  1398.     tst.l    d0
  1399.     bne.b    .again            ;error!
  1400.     bsr.w    mloadset_changeenv
  1401.     tst.l    d0
  1402.     bne.b    .error
  1403. .exit
  1404.     moveq    #0,d0
  1405. .error
  1406.     rts
  1407.  
  1408. ;in:
  1409. * d1    gammal sysfont
  1410. * d2    gammal screenmode
  1411. mloadset_changeenv:
  1412.     bsr    prefs2curr
  1413.  
  1414.     bsr    changeenv
  1415.     tst.l    d0
  1416.     bne.b    .error
  1417.     bsr.w    recountlines
  1418.     tst.l    d0
  1419.     bne.b    .error
  1420.  
  1421.     moveq    #1,d0
  1422. .error
  1423.     rts
  1424.  
  1425. msaveset:
  1426.     lea    setname,a0
  1427.     tst.b    (a0)
  1428.     bne.b    .saveit
  1429.  
  1430.     base    dos
  1431.     lea    defsetname(pc),a2
  1432.     move.l    a2,d1
  1433.     call    PathPart
  1434.     lea    temp,a0
  1435.     move.l    a2,a1
  1436. .loop
  1437.     move.b    (a1)+,(a0)+
  1438.     cmp.l    a1,d0
  1439.     bne.b    .loop
  1440.     clr.b    (a0)
  1441.     move.l    #temp,d1
  1442.     moveq    #ACCESS_READ,d2
  1443.     call    Lock
  1444.     tst.l    d0
  1445.     bne.b    .unlock
  1446.     move.l    #temp,d1
  1447.     call    CreateDir
  1448. .unlock
  1449.     move.l    d0,d1
  1450.     call    UnLock                ;NULL is ok
  1451.  
  1452.     move.l    a2,a0
  1453. .saveit
  1454.     bsr.w    savesettings
  1455.     tst.l    d0
  1456.     beq.b    .exit
  1457.     lea    savesetmessage(pc),a1
  1458.     lea    oktext(pc),a2
  1459.     suba.l    a4,a4
  1460.     bsr    requester
  1461. .exit
  1462.     moveq    #0,d0
  1463.     rts
  1464. msavesetas:
  1465. .again
  1466.     lea    setfreqtitle(pc),a0
  1467.     lea    savesettitle(pc),a1
  1468.     move.l    a1,(a0)
  1469.     move.l    #TRUE,setfreqsave
  1470.     base    asl
  1471.     move.l    setfreqptr(pc),a0
  1472.     lea    setfreqtags(pc),a1
  1473.     call    AslRequest
  1474.     tst.l    d0
  1475.     beq.s    .error
  1476.  
  1477.     move.l    setfreqptr(pc),a0
  1478.     move.l    fr_File(a0),a1
  1479.     move.l    fr_Drawer(a0),a0
  1480.     lea    temp,a2
  1481.     move.w    #tempsize,d0
  1482.     bsr.w    pathnfiletobuff
  1483.  
  1484.     lea    temp,a0
  1485.     bsr.W    savesettings
  1486.     tst.l    d0
  1487.     bmi.b    .again
  1488. .exit
  1489.     moveq    #0,d0
  1490. .error
  1491.     rts
  1492.  
  1493. ;in:
  1494. * a0    filename
  1495. ;ut:
  1496. * d0    0 if no error, else -1
  1497. loadsettings:
  1498.     pushm    d1-a6
  1499.  
  1500.     lea    .filename(pc),a1
  1501.     move.l    a0,(a1)
  1502.  
  1503.     bsr    curr2prefs
  1504.  
  1505.     move.l    .filename(pc),a0
  1506.     bsr    loadfile
  1507.     tst.l    d0
  1508.     bne.w    .error
  1509.     lea    .addr(pc),a1
  1510.     move.l    a0,(a1)
  1511.     lea    .memlen(pc),a1
  1512.     move.l    d1,(a1)
  1513.     lea    .len(pc),a1
  1514.     move.l    d2,(a1)
  1515.  
  1516.     lea    prefs_id(pc),a1
  1517. .testloop
  1518.     move.b    (a1)+,d0
  1519.     beq.b    .testok
  1520.     cmp.b    (a0)+,d0
  1521.     bne.w    .error
  1522.     bra.b    .testloop
  1523. .testok
  1524.  
  1525.     base    dos
  1526.  
  1527.     lea    prefs_longs(pc),a2
  1528. .longloop
  1529.     move.l    (a2)+,d0
  1530.     beq.b    .nomorelongs
  1531.     move.l    d0,a1
  1532.     move.l    .addr(pc),a0
  1533.     move.l    .len(pc),d0
  1534.     bsr    .getarg
  1535.     move.l    (a2)+,d2
  1536.     move.l    d0,d1
  1537.     beq.b    .longloop
  1538.     call    StrToLong
  1539.     bra.b    .longloop
  1540. .nomorelongs
  1541.  
  1542.     lea    prefs_words(pc),a2
  1543. .wordloop
  1544.     move.l    (a2)+,d0
  1545.     beq.b    .nomorewords
  1546.     move.l    d0,a1
  1547.     move.l    .addr(pc),a0
  1548.     move.l    .len(pc),d0
  1549.     bsr    .getarg
  1550.     move.l    (a2)+,a3
  1551.     lea    .templong(pc),a0
  1552.     move.l    a0,d2
  1553.     move.l    d0,d1
  1554.     beq.b    .wordloop
  1555.     call    StrToLong
  1556.     move.w    .templong+2(pc),(a3)
  1557.     bra.b    .wordloop
  1558. .nomorewords
  1559.  
  1560.     lea    prefs_strings(pc),a2
  1561. .stringloop
  1562.     move.l    (a2)+,d0
  1563.     beq.b    .nomorestrings
  1564.     move.l    d0,a1
  1565.     move.l    .addr(pc),a0
  1566.     move.l    .len(pc),d0
  1567.     bsr    .getarg
  1568.     move.l    (a2)+,a1
  1569.     tst.l    d0
  1570.     beq.b    .stringloop
  1571.     move.l    d0,a0
  1572. .stringcopy
  1573.     move.b    (a0)+,d0
  1574.     cmp.b    #LF,d0
  1575.     bne.b    .stringnolf
  1576.     moveq    #0,d0
  1577. .stringnolf
  1578.     move.b    d0,(a1)+
  1579.     bne.b    .stringcopy
  1580.     bra.b    .stringloop
  1581. .nomorestrings
  1582.  
  1583.  
  1584.     lea    prefs_palette(pc),a1
  1585.     move.l    .addr(pc),a0
  1586.     move.l    .len(pc),d0
  1587.     bsr    .getarg
  1588.     move.l    d0,d3
  1589.     beq.b    .nopalette
  1590.     lea    palette(pc),a2
  1591.     moveq    #3*(2^maxdepth)-1,d4
  1592. .paletteloop
  1593.     move.l    a2,d2
  1594.     move.l    d3,d1
  1595.     bsr    strtoulong
  1596.     addq.l    #1,d0
  1597.     beq.b    .nopalette
  1598.     addq.l    #1,d0
  1599.     add.l    d0,d3
  1600.     addq.l    #4,a2
  1601.     dbf    d4,.paletteloop
  1602. .nopalette
  1603.     lea    thisfont(pc),a0
  1604.     lea    thisfontname(pc),a1
  1605.     move.l    a1,(a0)
  1606.  
  1607.     move.w    #setnamelen-1,d0    ;save the name
  1608.     lea    setname,a1
  1609.     move.l    .filename(pc),a0
  1610. .copysetname
  1611.     move.b    (a0)+,(a1)+
  1612.     dbeq    d0,.copysetname
  1613.  
  1614.     moveq    #0,d2
  1615. .exit
  1616.     base    exec
  1617.     move.l    .addr(pc),a1
  1618.     move.l    .memlen(pc),d0
  1619.     beq.b    .nofileloaded
  1620.     call    FreeMem
  1621. .nofileloaded
  1622.     move.l    d2,d0
  1623.     popm    d1-a6
  1624.     rts
  1625. .error
  1626.     moveq    #-1,d2
  1627.     bra.b    .exit
  1628. .filehandle    dc.l    0
  1629. .filename    dc.l    0
  1630. .addr        dc.l    0
  1631. .memlen        dc.l    0
  1632. .len        dc.l    0
  1633. .templong    dc.l    0
  1634. ;in:
  1635. * a0    buffer to search
  1636. * a1    NULL-terminated keyword
  1637. * d0    length of buffer
  1638. ;ut:
  1639. * d0    pointer to argument or NULL if not found
  1640. .getarg
  1641.     pushm    d1/a0-a3
  1642.     subq.w    #1,d0
  1643. .getarg_loop2
  1644.     move.b    (a1),d1
  1645. .getarg_loop1
  1646.     cmp.b    (a0)+,d1
  1647.     dbeq    d0,.getarg_loop1
  1648.     tst.w    d0
  1649.     bmi.b    .getarg_notfound
  1650.  
  1651.     move.l    a0,a2
  1652.     move.l    a1,a3
  1653.     addq.l    #1,a3
  1654. .getarg_loop3
  1655.     move.b    (a3)+,d1
  1656.     beq.b    .getarg_found
  1657.     cmp.b    (a2)+,d1
  1658.     beq.b    .getarg_loop3
  1659.     bra.b    .getarg_loop2
  1660. .getarg_found
  1661.     move.l    a2,d0
  1662.     addq.l    #1,d0
  1663.     bra.b    .getarg_exit
  1664. .getarg_notfound
  1665.     moveq    #0,d0
  1666. .getarg_exit
  1667.     popm    d1/a0-a3
  1668.     rts
  1669.  
  1670. in:
  1671. * a0    filename
  1672. ;ut:
  1673. * d0    0 if no error, else -1
  1674. savesettings:
  1675.     bsr    curr2prefs
  1676.     base    dos
  1677.     move.l    a0,d1
  1678.     lea    .filename(pc),a1
  1679.     move.l    a0,(a1)
  1680.     move.l    #MODE_NEWFILE,d2
  1681.     call    Open
  1682.     lea    .filehandle(pc),a0
  1683.     move.l    d0,(a0)
  1684.     beq.w    .error
  1685.     move.l    d0,d3
  1686.     lea    prefs_id(pc),a0
  1687.     move.l    a0,d2
  1688.     move.l    d3,d1
  1689.     call    FPuts
  1690.     lea    prefs_version(pc),a0
  1691.     move.l    a0,d2
  1692.     move.l    d3,d1
  1693.     call    FPuts
  1694.  
  1695.     lea    prefs_longs(pc),a2
  1696. .longloop
  1697.     move.l    (a2)+,d2
  1698.     beq.b    .nomorelongs
  1699.     move.l    d3,d1
  1700.     call    FPuts
  1701.     move.l    d3,d1
  1702.     moveq    #"=",d2
  1703.     call    FPutC
  1704.     move.l    (a2)+,a0
  1705.     move.l    (a0),d0
  1706.     bsr    numdec
  1707.     move.l    d0,d2
  1708.     move.l    d3,d1
  1709.     call    FPuts
  1710.     move.l    d3,d1
  1711.     moveq    #LF,d2
  1712.     call    FPutC
  1713.     bra.b    .longloop
  1714. .nomorelongs
  1715.  
  1716.     lea    prefs_words(pc),a2
  1717. .wordloop
  1718.     move.l    (a2)+,d2
  1719.     beq.b    .nomorewords
  1720.     move.l    d3,d1
  1721.     call    FPuts
  1722.     move.l    d3,d1
  1723.     moveq    #"=",d2
  1724.     call    FPutC
  1725.     move.l    (a2)+,a0
  1726.     moveq    #0,d0
  1727.     move.w    (a0),d0
  1728.     bsr    numdec
  1729.     move.l    d0,d2
  1730.     move.l    d3,d1
  1731.     call    FPuts
  1732.     move.l    d3,d1
  1733.     moveq    #LF,d2
  1734.     call    FPutC
  1735.     bra.b    .wordloop
  1736. .nomorewords
  1737.  
  1738.     lea    prefs_strings(pc),a2
  1739. .stringloop
  1740.     move.l    (a2)+,d2
  1741.     beq.b    .nomorestrings
  1742.     move.l    d3,d1
  1743.     call    FPuts
  1744.     move.l    d3,d1
  1745.     moveq    #"=",d2
  1746.     call    FPutC
  1747.     move.l    (a2)+,d2
  1748.     move.l    d3,d1
  1749.     call    FPuts
  1750.     move.l    d3,d1
  1751.     moveq    #LF,d2
  1752.     call    FPutC
  1753.     bra.b    .stringloop
  1754. .nomorestrings
  1755.  
  1756.     lea    prefs_palette(pc),a0
  1757.     move.l    d3,d1
  1758.     move.l    a0,d2
  1759.     call    FPuts
  1760.     move.l    d3,d1
  1761.     moveq    #"=",d2
  1762.     call    FPutC
  1763.     lea    palette(pc),a2
  1764.     move.l    (a2)+,d0
  1765.     bsr    numdec
  1766.     move.l    d0,d2
  1767.     move.l    d3,d1
  1768.     call    FPuts
  1769.     moveq    #3*(2^maxdepth)-1-1,d4
  1770. .paletteloop
  1771.     move.l    d3,d1
  1772.     moveq    #",",d2
  1773.     call    FPutC
  1774.     move.l    (a2)+,d0
  1775.     bsr    numdec
  1776.     move.l    d0,d2
  1777.     move.l    d3,d1
  1778.     call    FPuts
  1779.     dbf    d4,.paletteloop
  1780.     move.l    d3,d1
  1781.     moveq    #LF,d2
  1782.     call    FPutC
  1783.  
  1784.     lea    createicons(pc),a0
  1785.     tst.w    (a0)
  1786.     beq.b    .noicon
  1787.     base    icon
  1788.     lea    .defprefsiconname(pc),a0
  1789.     call    GetDiskObject
  1790.     move.l    d0,d2
  1791.     move.l    d0,a1
  1792.     bne.b    .nodefprefsicon
  1793.     lea    Textread_prefs,a1    ;builtin icon
  1794. .nodefprefsicon
  1795.     move.l    .filename(pc),a0
  1796.     call    PutDiskObject
  1797.     tst.l    d2
  1798.     beq.b    .nodefprefsicon2
  1799.     move.l    d2,a0
  1800.     call    FreeDiskObject
  1801. .nodefprefsicon2
  1802. .noicon
  1803.     base    dos
  1804.     move.l    .filehandle(pc),d1
  1805.     call    Close
  1806.  
  1807.     move.l    .filename(pc),a0
  1808.     lea    setname,a1
  1809. .copysetname
  1810.     move.b    (a0)+,(a1)+
  1811.     bne.b    .copysetname
  1812.  
  1813.     moveq    #0,d0
  1814.     rts
  1815. .error
  1816.     moveq    #-1,d0
  1817.     rts
  1818.  
  1819. .filehandle    dc.l    0
  1820. .filename    dc.l    0
  1821. .defprefsiconname
  1822.     dc.b    "ENV:Textread/def_prefs",0
  1823.     even
  1824.  
  1825. prefs_longs
  1826.     dc.l    prefs_tabsize,tabsize
  1827.     dc.l    prefs_displayid,setdisplayid
  1828.     dc.l    prefs_screendepth,setscreendepth
  1829.     dc.l    0
  1830. prefs_words
  1831.     dc.l    prefs_fontsize,thisfontsize
  1832.     dc.l    prefs_createicons,setcreateicons
  1833.     dc.l    prefs_wordwrap,setwordwrap
  1834.     dc.l    prefs_sysfont,setsysfont
  1835.     dc.l    prefs_remansi,setalwaysremansi
  1836.     dc.l    prefs_remcr,setalwaysremcr
  1837.     dc.l    prefs_nofontfake,setnofontfake
  1838.     dc.l    prefs_legalprint,setlegalprint
  1839.     dc.l    prefs_fontcheck,setfontcheck
  1840.     dc.l    0
  1841. prefs_strings
  1842.     dc.l    prefs_fontname,thisfontname
  1843.     dc.l    prefs_filereqdir,filereqdir
  1844.     dc.l    prefs_filereqpat,filereqpat
  1845.     dc.l    0
  1846.  
  1847. prefs_id    dc.b    "Textread settings",10,0
  1848. prefs_id_len    =*-prefs_id
  1849.  
  1850. prefs_version
  1851.     dc.b    "$VER: Textread "
  1852.     versionstr
  1853.     dc.b    "."
  1854.     revisionstr
  1855.     dc.b    " ("
  1856.     date
  1857.     dc.b    ")",10,10,0
  1858.  
  1859. prefs_tabsize        dc.b    "TABSIZE",0
  1860. prefs_fontname        dc.b    "FONTNAME",0
  1861. prefs_fontsize        dc.b    "FONTSIZE",0
  1862. prefs_filereqdir    dc.b    "REQDIR",0
  1863. prefs_filereqpat    dc.b    "REQPATTERN",0
  1864. prefs_createicons    dc.b    "CREATEICONS",0
  1865. prefs_wordwrap        dc.b    "WORDWRAP",0
  1866. prefs_sysfont        dc.b    "SYSFONT",0
  1867. prefs_remansi        dc.b    "REMANSI",0
  1868. prefs_remcr        dc.b    "REMCR",0
  1869. prefs_nofontfake    dc.b    "NOFONTFAKE",0
  1870. prefs_legalprint    dc.b    "LEGALPRINT",0
  1871. prefs_fontcheck        dc.b    "CHECKFONT",0
  1872. prefs_displayid        dc.b    "DISPLAYID",0
  1873. prefs_palette        dc.b    "PALETTE",0
  1874. prefs_screendepth    dc.b    "SCREENDEPTH",0
  1875.     even
  1876.  
  1877. createicons:
  1878.     dc.w    0
  1879. mcreateicons:
  1880.     lea    createicons(pc),a1
  1881.     bsr.w    checkmark
  1882.     moveq    #0,d0
  1883.     rts
  1884.  
  1885. mprefs2all:
  1886.     bsr    multi_prefs2all
  1887.     moveq    #0,d0
  1888.     rts
  1889.  
  1890. ********************************************************************** commands
  1891.  
  1892. msearch:
  1893.     bra.w    search
  1894. msearchnext:
  1895.     bra.w    searchnext
  1896. msearchprev:
  1897.     bra.w    searchprev
  1898.  
  1899. medittext:
  1900.     bra.w    vedittext
  1901. mremansi:
  1902.     bsr.b    RemoveANSI
  1903.     bsr.w    countlines
  1904.     tst.l    d0
  1905.     bne.b    .error
  1906.     bsr.w    textredraw
  1907.     moveq    #0,d0
  1908. .error
  1909.     rts
  1910. mremcr:
  1911.     bsr.w    RemoveCR
  1912.     bsr.w    countlines
  1913.     tst.l    d0
  1914.     bne.b    .error
  1915.     bsr.w    textredraw
  1916.     moveq    #0,d0
  1917. .error
  1918.     rts
  1919.  
  1920. RemoveANSI:
  1921.     tst.l    filememlen
  1922.     beq.b    .exit
  1923.     Message    remansitext
  1924.     move.l    fileaddr(pc),a0
  1925.     move.l    a0,a1
  1926.     add.l    filelen(pc),a1
  1927.     bsr.b    .RemoveANSI
  1928.     move.l    fileaddr(pc),d1
  1929.     sub.l    d1,d0
  1930.     lea    filelen(pc),a0
  1931.     move.l    d0,(a0)
  1932.     Message    screentitle
  1933. .exit
  1934.     moveq    #0,d0
  1935.     rts
  1936.     even
  1937. ;in:
  1938. * a0    text
  1939. * a1    textend
  1940. ;ut:
  1941. * d0    nytt textend
  1942. .RemoveANSI
  1943.     move.l    a0,a2
  1944.     move.l    a0,a4            ;save beginning
  1945.     moveq    #$1b,d7            ;ESC
  1946.     moveq    #$9b-256,d6        ;CSI    (moveq.b #$9b,d6)
  1947.     moveq    #8,d5            ;BS
  1948. .loop
  1949.     move.b    (a0)+,d0
  1950.     cmp.b    d7,d0            ;Esc
  1951.     bne.b    .inteESC
  1952.  
  1953.     move.l    a0,a3
  1954.  
  1955.     move.b    (a3)+,d1
  1956.  
  1957.     cmp.b    #"[",d1
  1958.     beq.b    .csi_loop        ;*NOT* ISO/ANSI, but often used.
  1959.  
  1960.     cmp.b    #" ",d1
  1961.     blo.b    .dontremove
  1962.     cmp.b    #"/",d1
  1963.     bhi.b    .dontremove
  1964.  
  1965. .esc_loop
  1966.     move.b    (a3)+,d1
  1967.     cmp.b    #" ",d1
  1968.     blo.b    .esc_last
  1969.     cmp.b    #"/",d1
  1970.     bhi.b    .esc_last
  1971.     cmp.l    a1,a3
  1972.     blo.b    .esc_loop
  1973.     bra.b    .dontremove
  1974. .esc_last
  1975.     move.b    -1(a3),d1
  1976.     cmp.b    #"0",d1
  1977.     blo.b    .dontremove
  1978.     cmp.b    #"~",d1
  1979.     bhi.b    .dontremove
  1980.  
  1981.     move.l    a3,a0            ;Remove!
  1982.     bra.b    .nextchar
  1983. .inteESC
  1984.     cmp.b    d6,d0            ;CSI
  1985.     bne.b    .inteCSI
  1986.  
  1987.     move.l    a0,a3
  1988.  
  1989.     move.b    (a3)+,d1
  1990.     cmp.b    #" ",d1
  1991.     blo.b    .dontremove
  1992.     cmp.b    #"?",d1
  1993.     bhi.b    .dontremove
  1994.  
  1995. .csi_loop
  1996.     move.b    (a3)+,d1
  1997.     cmp.b    #" ",d1
  1998.     blo.b    .csi_last
  1999.     cmp.b    #"?",d1
  2000.     bhi.b    .csi_last
  2001.     cmp.l    a1,a3
  2002.     blo.b    .csi_loop
  2003.     bra.b    .dontremove
  2004. .csi_last
  2005.     move.b    -1(a3),d1
  2006.     cmp.b    #"@",d1
  2007.     blo.b    .dontremove
  2008.     cmp.b    #"~",d1
  2009.     bhi.b    .dontremove
  2010.     move.l    a3,a0            ;Remove!
  2011.     bra.b    .nextchar
  2012. .inteCSI
  2013.     cmp.b    d5,d0            ;BS
  2014.     bne.s    .inteBS
  2015.     cmp.l    a2,a4
  2016.     beq.s    .nextchar
  2017.     subq.l    #1,a2            ;remove prev char
  2018.     bra.s    .nextchar
  2019. .inteBS
  2020. .dontremove
  2021.     move.b    d0,(a2)+
  2022. .nextchar
  2023.     cmp.l    a1,a0
  2024.     blo.w    .loop
  2025.     move.l    a2,d0
  2026.     rts
  2027.  
  2028. RemoveCR:
  2029.     tst.l    filememlen
  2030.     beq.b    .exit
  2031.     Message    remcrtext
  2032.     move.l    fileaddr(pc),a0
  2033.     move.l    a0,a1
  2034.     add.l    filelen(pc),a1
  2035.     bsr.b    .RemoveCR
  2036.     move.l    fileaddr(pc),d1
  2037.     sub.l    d1,d0
  2038.     lea    filelen(pc),a0
  2039.     move.l    d0,(a0)
  2040.     Message    screentitle
  2041. .exit
  2042.     moveq    #0,d0
  2043.     rts
  2044. ;in:
  2045. * a0    text
  2046. * a1    textend
  2047. ;ut:
  2048. * d0    nytt textend
  2049. .RemoveCR
  2050.     move.l    a0,a2
  2051.     moveq    #13,d2
  2052. .loop
  2053.     move.b    (a0)+,d0
  2054.     cmp.b    d2,d0            ; ascii 13
  2055.     beq.b    .CR
  2056.     move.b    d0,(a2)+
  2057. .CR
  2058.     cmp.l    a0,a1
  2059.     bhi.b    .loop
  2060.     move.l    a2,d0
  2061.     rts
  2062.  
  2063. *******************************************************************************
  2064. rawkey:
  2065.     cmp.w    #$5f,d3            ;help
  2066.     beq.w    printhelp
  2067.     cmp.w    #$4c,d3
  2068.     beq.W    .crsrup
  2069.     cmp.w    #$4d,d3
  2070.     beq.W    .crsrdown
  2071.     cmp.w    #$4e,d3
  2072.     beq.s    .crsrright
  2073.     cmp.w    #$4f,d3
  2074.     beq.s    .crsrleft
  2075.     cmp.w    #$50,d3
  2076.     blo.b    .notf
  2077.     cmp.w    #$59,d3
  2078.     bls.w    .fkeys
  2079. .notf
  2080.     moveq    #0,d0
  2081.     rts
  2082. .crsrleft
  2083.     move.w    d4,d0
  2084.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2085.     bne.w    prevpage3
  2086.     move.w    d4,d0
  2087.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2088.     bne.w    prevbuff
  2089.     bra.w    prevpage
  2090. .crsrright
  2091.     move.w    d4,d0
  2092.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2093.     bne.w    nextpage3
  2094.     move.w    d4,d0
  2095.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2096.     bne.w    nextbuff
  2097.     bra.w    nextpage
  2098. .crsrup
  2099.     move.w    d4,d0
  2100.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2101.     bne.w    prevpage
  2102.     move.w    d4,d0
  2103.     and.w    #IEQUALIFIER_CONTROL,d0
  2104.     bne.w    gotop
  2105.     move.w    d4,d0
  2106.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2107.     bne.w    prevpage3
  2108.     bra.w    scrolldown1
  2109. .crsrdown
  2110.     move.w    d4,d0
  2111.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2112.     bne.w    nextpage
  2113.     move.w    d4,d0
  2114.     and.w    #IEQUALIFIER_CONTROL,d0
  2115.     bne.w    gobottom
  2116.     move.w    d4,d0
  2117.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2118.     bne.w    nextpage3
  2119.     bra.w    scrollup1
  2120. .fkeys
  2121.     sub.w    #$50,d3
  2122.     lsl.w    #2,d3
  2123.     lea    fkeys_lines(pc),a0
  2124.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d4
  2125.     beq.b    .fkeys_goto
  2126.     move.l    linepos(pc),(a0,d3.w)
  2127.     moveq    #0,d0
  2128.     rts
  2129. .fkeys_goto
  2130.     lea    linepos(pc),a1
  2131.     move.l    (a0,d3.w),d0
  2132.     cmp.l    #-1,d0
  2133.     beq.b    .fkeys_exit
  2134.     move.l    d0,(a1)
  2135.     bsr.w    textredraw
  2136. .fkeys_exit
  2137.     moveq    #0,d0
  2138.     rts
  2139. fkeys_lines:
  2140.     dc.l    -1,-1,-1,-1,-1,-1,-1,-1,-1,-1
  2141. fkeys_lines_size    =*-fkeys_lines
  2142. *******************************************************************************
  2143. vanillakey:
  2144.     cmp.w    #$0003,d3
  2145.     beq.w    vctrl_c
  2146.     cmp.w    #$001b,d3
  2147.     beq.w    vesc
  2148.     cmp.w    #"q",d3
  2149.     beq.w    vquit
  2150.  
  2151.     cmp.w    #"?",d3
  2152.     beq.w    vhelp
  2153.     cmp.w    #"h",d3
  2154.     beq.w    vhelp
  2155.  
  2156.     cmp.w    #"w",d3
  2157.     beq.w    vwordwrap
  2158.     cmp.w    #TAB,d3
  2159.     beq.w    mtabsize
  2160.  
  2161.     cmp.w    #"A",d3
  2162.     beq.w    mremansi
  2163.     cmp.w    #"C",d3
  2164.     beq.w    mremcr
  2165.  
  2166.     cmp.w    #"#",d3
  2167.     beq.w    vnummer
  2168.     cmp.w    #"l",d3
  2169.     beq.w    vl
  2170.     cmp.w    #"g",d3
  2171.     beq.w    vg
  2172.     cmp.w    #"%",d3
  2173.     beq.w    vprosenten
  2174.  
  2175.     cmp.w    #"t",d3
  2176.     beq.w    gotop
  2177.     cmp.w    #"<",d3
  2178.     beq.w    gotop
  2179.  
  2180.     cmp.w    #"b",d3
  2181.     beq.w    gobottom
  2182.     cmp.w    #">",d3
  2183.     beq.w    gobottom
  2184.  
  2185.     btst    #IEQUALIFIERB_NUMERICPAD,d4
  2186.     beq.b    .nonumpad
  2187.     cmp.w    #"7",d3
  2188.     beq.w    gotop
  2189.  
  2190.     cmp.w    #"1",d3
  2191.     beq.w    gobottom
  2192.  
  2193.     cmp.w    #"9",d3
  2194.     beq.w    prevpagescroll
  2195.     cmp.w    #"3",d3
  2196.     beq.w    nextpagescroll
  2197.  
  2198.     cmp.w    #"8",d3
  2199.     beq.w    .smoothdown
  2200.  
  2201.     cmp.w    #"2",d3
  2202.     beq.w    .smoothup
  2203.     bra.b    .numpadok
  2204. .nonumpad
  2205.     cmp.w    #"0",d3
  2206.     blo.b    .not1to0
  2207.     cmp.w    #"9",d3
  2208.     bhi.b    .not1to0
  2209.     sub.w    #"0"+1,d3
  2210.     bpl.b    .buffnumok
  2211.     moveq    #9,d3
  2212. .buffnumok
  2213.     moveq    #0,d0
  2214.     move.w    d3,d0
  2215.     bra    multi_change
  2216. .not1to0
  2217. .numpadok
  2218.     cmp.w    #"+",d3
  2219.     beq    nextbuff
  2220.     cmp.w    #"-",d3
  2221.     beq    prevbuff
  2222.  
  2223.     cmp.w    #" ",d3
  2224.     beq.w    nextpage
  2225.     cmp.w    #8,d3            ;bs
  2226.     beq.w    prevpage
  2227.     cmp.w    #13,d3
  2228.     beq.w    scrollup1
  2229.  
  2230.     cmp.w    #"E",d3
  2231.     beq.w    vedittext
  2232.  
  2233.     cmp.w    #"s",d3
  2234.     beq.w    vsearchnocase
  2235.     cmp.w    #".",d3
  2236.     beq.w    vsearchnocase
  2237.     cmp.w    #"S",d3
  2238.     beq.w    vsearchcase
  2239.     cmp.w    #"/",d3
  2240.     beq.w    vsearchcase
  2241.  
  2242.     cmp.w    #"n",d3
  2243.     beq.w    vsearchnext
  2244.     cmp.w    #"p",d3
  2245.     beq.w    searchprev
  2246.  
  2247.     moveq    #0,d0
  2248.     rts
  2249.  
  2250. .smoothup
  2251.     moveq    #0,d1            ;->
  2252.     bra.b    .smooth
  2253. .smoothdown
  2254.     moveq    #1,d1            ;->
  2255. .smooth
  2256.     lea    scrollfart(pc),a0
  2257.     lea    scrolla(pc),a1
  2258.  
  2259.     move.w    d4,d0
  2260.     and.w    #IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,d0
  2261.     beq.s    .smoothup_noshift
  2262.     move.w    #3,(a0)
  2263.     move.w    #scrolla_crsr,(a1)
  2264.     bra.s    .smoothup_exit
  2265. .smoothup_noshift
  2266.     move.w    d4,d0
  2267.     and.w    #IEQUALIFIER_CONTROL,d0
  2268.     beq.s    .smoothup_nocontrol
  2269.     move.w    #1,(a0)
  2270.     move.w    #scrolla_crsr,(a1)
  2271.     bra.s    .smoothup_exit
  2272. .smoothup_nocontrol
  2273.     move.w    d4,d0
  2274.     and.w    #IEQUALIFIER_LALT!IEQUALIFIER_RALT,d0
  2275.     beq.s    .smoothup_noalt
  2276.     move.w    #4,(a0)
  2277.     move.w    #scrolla_crsr,(a1)
  2278.     bra.s    .smoothup_exit
  2279. .smoothup_noalt
  2280.     move.w    #2,(a0)
  2281.     move.w    #scrolla_crsr,(a1)
  2282. .smoothup_exit
  2283.     tst.l    d1            ;<-
  2284.     beq.b    .smoothup_quit
  2285.     neg.w    (a0)
  2286. .smoothup_quit
  2287.     moveq    #0,d0
  2288.     rts
  2289.  
  2290.  
  2291. vesc:
  2292.     and.w    #IEQUALIFIER_RSHIFT!IEQUALIFIER_LSHIFT,d4
  2293.     bne.b    vquit
  2294.     bsr    mclose
  2295.     moveq    #0,d0
  2296.     rts
  2297. vctrl_c:
  2298. vquit:
  2299.     bsr.w    mquit
  2300.     moveq    #0,d0
  2301.     rts
  2302. vhelp:
  2303.     bsr.w    printhelp
  2304.     moveq    #0,d0
  2305.     rts
  2306. vwordwrap:
  2307.     eor.w    #1,wordwrap
  2308.     bsr.w    updatecheckmarks
  2309.     bsr.w    countlines
  2310.     tst.l    d0
  2311.     bne.b    .exit
  2312.     bsr.w    textredraw
  2313.     moveq    #0,d0
  2314. .exit
  2315.     rts
  2316. vnummer:
  2317. vl:
  2318.  
  2319.     jsr    requestline
  2320.  
  2321.     tst.l    d0
  2322.     bmi.b    .error
  2323.     beq.b    .exit
  2324.  
  2325.     lea    linepos(pc),a0
  2326.     move.l    d1,(a0)
  2327.     bsr.w    textredraw
  2328. .exit
  2329.     moveq    #0,d0
  2330. .error
  2331.     rts
  2332.  
  2333. vprosenten:
  2334. vg:
  2335.     jsr    requestpercent
  2336.  
  2337.     tst.l    d0
  2338.     bmi.b    .error
  2339.     beq.b    .exit
  2340.  
  2341.     move.l    lines(pc),d0
  2342.     sub.l    cheight(pc),d0
  2343.     mulu.w    d1,d0
  2344.     add.l    #50,d0            ;round
  2345.     divu.w    #100,d0
  2346.     and.l    #$0000ffff,d0
  2347.     lea    linepos(pc),a0
  2348.     move.l    d0,(a0)
  2349.  
  2350.     bsr.w    textredraw
  2351. .exit
  2352.     moveq    #0,d0
  2353. .error
  2354.     rts
  2355.  
  2356. vsearchnocase:
  2357.     clr.w    search_case
  2358.     bsr.w    updatecheckmarks
  2359.     bra.w    search
  2360. vsearchcase:
  2361.     move.w    #1,search_case
  2362.     bsr.w    updatecheckmarks
  2363.     bra.w    search
  2364. vsearchnext:
  2365.     bra.w    searchnext
  2366. vedittext:
  2367.     lea.l    filelen(pc),a0
  2368.     tst.l    (a0)
  2369.     beq.B    .nofile
  2370.     base    dos
  2371.     lea    .editor(pc),a0
  2372.     move.l    a0,d1
  2373.     lea    temp,a2
  2374.     move.l    a2,d2
  2375.     move.l    #tempsize,d3
  2376.     moveq    #0,d4
  2377.     call    GetVar
  2378.     tst.l    d0
  2379.     beq.b    .error
  2380.     cmp.l    #-1,d0
  2381.     beq.b    .error
  2382.     add.l    d0,a2
  2383.     move.b    #" ",(a2)+
  2384.     move.b    #'"',(a2)+
  2385.  
  2386.     move.l    a2,d1
  2387.     lea    filereqdir(pc),a1
  2388. .copydir
  2389.     move.b    (a1)+,(a2)+
  2390.     bne.B    .copydir
  2391.     lea    filename(pc),a0        ;d1 already ok
  2392.     move.l    a0,d2
  2393.     lea    tempend-1,a0
  2394.     move.l    a0,d3
  2395.     sub.l    d1,d3            ;size
  2396.     call    AddPart
  2397.     tst.l    d0
  2398.     beq.b    .error
  2399.     lea    temp,a0
  2400.     move.l    a0,d1
  2401. .findnull
  2402.     tst.b    (a0)+
  2403.     bne.b    .findnull
  2404.     move.b    #'"',-1(a0)
  2405.     clr.b    (a0)
  2406.  
  2407.     lea    .tags(pc),a0
  2408.     move.l    a0,d2
  2409.     call    SystemTagList
  2410. .error
  2411.     moveq    #0,d0
  2412.     rts
  2413. .nofile
  2414.     lea    nofileloaded(pc),a1
  2415.     lea    oktext(pc),a2
  2416.     suba.l    a4,a4
  2417.     bsr.w    requester
  2418.     moveq    #0,d0
  2419.     rts
  2420. .editor    dc.b    "editor",0
  2421.     even
  2422. .tags    
  2423.     dc.l    SYS_Asynch,TRUE        ;
  2424.     dc.l    SYS_UserShell,TRUE
  2425.     dc.l    TAG_DONE
  2426. *******************************************************************************
  2427. refreshwindow:
  2428.     base    gt
  2429.     move.l    windowptr(pc),a0
  2430.     call    GT_BeginRefresh
  2431.     move.l    windowptr(pc),a0
  2432.     moveq    #TRUE,d0
  2433.     call    GT_EndRefresh
  2434.     moveq    #0,d0
  2435.     rts
  2436. *******************************************************************************
  2437. handlegadgets:
  2438.     cmp.l    scrollgadget(pc),a2
  2439.     beq.B    .scrollgadget
  2440.     cmp.l    quitgadget(pc),a2
  2441.     beq.B    .quitgadget
  2442.     moveq    #0,d0
  2443.     rts
  2444. .scrollgadget
  2445.     bsr.w    fixlinepos        ;scroll or redraw full page?
  2446.     move.l    cheight(pc),d2
  2447.     subq.l    #3,d2            ;???
  2448.     mulu.w    fonty+2(pc),d2
  2449.     lea    linepos(pc),a0
  2450.     move.l    d3,d0
  2451.     sub.l    (a0),d0
  2452.     muls.w    fonty+2(pc),d0
  2453.     moveq    #1,d1
  2454.     cmp.l    d2,d0
  2455.     bls.w    scrollup_noupdate    ;unsigned
  2456.     neg.l    d2
  2457.     cmp.l    d2,d0
  2458.     bls.s    .notprevline        ;unsigned
  2459.     neg.l    d0
  2460.     bra.w    scrolldown_noupdate
  2461. .notprevline
  2462.     move.l    d3,(a0)            ;code
  2463.     bsr.w    changenum
  2464.     bsr.w    cls
  2465.     move.l    linepos(pc),d0
  2466.     bsr.w    gotoline
  2467.     bsr.w    printpage
  2468.     moveq    #0,d0
  2469.     rts
  2470. .quitgadget
  2471.     bsr    mquit
  2472.     moveq    #0,d0
  2473.     rts
  2474. *******************************************************************************
  2475. handlebuttons:
  2476.     cmp.w    #SELECTDOWN,d3
  2477.     bne.s    .nodown
  2478.     lea    scrolla(pc),a0
  2479.     move.w    #scrolla_mouse,(a0)
  2480. .nodown
  2481.     cmp.w    #SELECTUP,d3
  2482.     bne.s    .noup
  2483.     lea    scrolla(pc),a0        ;stop scrolling
  2484.     clr.w    (a0)
  2485. .noup
  2486.     moveq    #0,d0
  2487.     rts
  2488.  
  2489.  
  2490. *******************************************************************************
  2491. ********************** S U B R U T I N E R ************************************
  2492. *******************************************************************************
  2493.  
  2494. **** prefs
  2495.  
  2496. ;call after new settings has been loaded
  2497. prefs2curr:
  2498.     move.w    setcreateicons(pc),createicons
  2499.     move.w    setwordwrap(pc),wordwrap
  2500.     move.w    setalwaysremansi(pc),alwaysremansi
  2501.     move.w    setalwaysremcr(pc),alwaysremcr
  2502.     move.w    setnofontfake(pc),nofontfake
  2503.     move.w    setlegalprint(pc),legalprint
  2504.     move.w    setfontcheck(pc),fontcheck
  2505.  
  2506.     move.w    setsysfont(pc),sysfont
  2507.     move.l    setdisplayid(pc),displayid
  2508.     move.l    setscreendepth(pc),screendepth
  2509.  
  2510.     pushm    d0-a6
  2511.     lea    palette(pc),a1
  2512.     bsr    changepalette
  2513.     popm    d0-a6
  2514.     rts
  2515.  
  2516. ;call before new settins will be loaded
  2517. curr2prefs:
  2518.     move.w    createicons(pc),setcreateicons
  2519.     move.w    wordwrap(pc),setwordwrap
  2520.     move.w    nofontfake(pc),setnofontfake
  2521.     move.w    legalprint(pc),setlegalprint
  2522.     move.w    fontcheck(pc),setfontcheck
  2523.     move.w    alwaysremcr(pc),setalwaysremcr
  2524.     move.w    alwaysremansi(pc),setalwaysremansi
  2525.  
  2526.     move.w    sysfont(pc),setsysfont
  2527.     move.l    displayid(pc),setdisplayid
  2528.     move.l    screendepth(pc),setscreendepth
  2529.  
  2530.     pushm    d0-a6
  2531.     lea    palette(pc),a1
  2532.     bsr    getpalette
  2533.     popm    d0-a6
  2534.     rts
  2535.  
  2536. **** buffer
  2537.  
  2538. nextbuff:
  2539.     move.l    bnum(pc),d0
  2540.     cmp.l    bmax(pc),d0
  2541.     bpl.b    .exit
  2542. ;    addq.l    #1-1,d0            ;bnum: 1-...
  2543.     bsr    multi_change
  2544. .exit
  2545.     moveq    #0,d0
  2546.     rts
  2547. prevbuff:
  2548.     move.l    bnum(pc),d0
  2549.     cmp.l    #1,d0
  2550.     beq.b    .exit
  2551.     subq.l    #1+1,d0            ;bnum begins at 1, not 0
  2552.     bsr    multi_change
  2553. .exit
  2554.     moveq    #0,d0
  2555.     rts
  2556.  
  2557. ;level 1
  2558.  
  2559. ;ut:
  2560. * d0    NULL om fel.
  2561. multi_init:
  2562.     pushm    a0
  2563.     lea    bufflist(pc),a0
  2564.     NEWLIST    a0
  2565.     bsr    multi_addbuff
  2566.     lea    thisbuff(pc),a0
  2567.     move.l    d0,(a0)
  2568.     pop    a0
  2569.     rts
  2570. ;in:
  2571. * a0    buffert
  2572. multi_curr2buff:
  2573.     pushm    d0/a0-a2
  2574.     move.l    fileaddr(pc),buff_fileaddr(a0)
  2575.     move.l    filelen(pc),buff_filelen(a0)
  2576.     move.l    filememlen(pc),buff_filememlen(a0)
  2577.     move.l    linepos(pc),buff_linepos(a0)
  2578.     move.l    lines(pc),buff_lines(a0)
  2579.     move.l    linelen(pc),buff_linelen(a0)
  2580.     move.l    linelensize(pc),buff_linelensize(a0)
  2581.  
  2582.     bsr    curr2prefs
  2583.  
  2584.     moveq    #32-1,d0
  2585.     lea    filename(pc),a1
  2586.     lea    buff_filename(a0),a2
  2587. .copyfilename
  2588.     move.b    (a1)+,(a2)+
  2589.     dbf    d0,.copyfilename
  2590.  
  2591.     move.w    #setnamelen-1,d0
  2592.     lea    setname,a1
  2593.     lea    buff_setname(a0),a2
  2594. .copysetname
  2595.     move.b    (a1)+,(a2)+
  2596.     dbf    d0,.copysetname
  2597.  
  2598.     move.w    #settings_len-1,d0
  2599.     lea    settings(pc),a1
  2600.     lea    buff_settings(a0),a2
  2601. .copysettings
  2602.     move.b    (a1)+,(a2)+
  2603.     dbf    d0,.copysettings
  2604.  
  2605.     move.w    #fkeys_lines_size-1,d0
  2606.     lea    fkeys_lines(pc),a1
  2607.     lea    buff_fkeys(a0),a2
  2608. .copyfkeys
  2609.     move.b    (a1)+,(a2)+
  2610.     dbf    d0,.copyfkeys
  2611.  
  2612.     popm    d0/a0-a2
  2613.     rts
  2614.  
  2615. ;in:
  2616. * a0    buffert
  2617. multi_buff2curr:
  2618.     pushm    d0/a0-a2
  2619.     move.l    buff_fileaddr(a0),fileaddr
  2620.     move.l    buff_filelen(a0),filelen
  2621.     move.l    buff_filememlen(a0),filememlen
  2622.     move.l    buff_linepos(a0),linepos
  2623.     move.l    buff_lines(a0),lines
  2624.     move.l    buff_linelen(a0),linelen
  2625.     move.l    buff_linelensize(a0),linelensize
  2626.  
  2627.     moveq    #32-1,d0
  2628.     lea    buff_filename(a0),a1
  2629.     lea    filename(pc),a2
  2630. .copyfilename
  2631.     move.b    (a1)+,(a2)+
  2632.     dbf    d0,.copyfilename
  2633.  
  2634.     move.w    #setnamelen-1,d0
  2635.     lea    buff_setname(a0),a1
  2636.     lea    setname,a2
  2637. .copysetname
  2638.     move.b    (a1)+,(a2)+
  2639.     dbf    d0,.copysetname
  2640.  
  2641.     move.w    #settings_len-1,d0
  2642.     lea    buff_settings(a0),a1
  2643.     lea    settings(pc),a2
  2644. .copysettings
  2645.     move.b    (a1)+,(a2)+
  2646.     dbf    d0,.copysettings
  2647.  
  2648.     move.w    #fkeys_lines_size-1,d0
  2649.     lea    buff_fkeys(a0),a1
  2650.     lea    fkeys_lines(pc),a2
  2651. .copyfkeys
  2652.     move.b    (a1)+,(a2)+
  2653.     dbf    d0,.copyfkeys
  2654.  
  2655.     bsr    prefs2curr
  2656.  
  2657.     popm    d0/a0-a2
  2658.     rts
  2659.  
  2660. multi_clearcurr:
  2661.     clr.l    fileaddr
  2662.     clr.l    filelen
  2663.     clr.l    filememlen
  2664.     clr.l    linepos
  2665.     move.l    #1,lines
  2666.     move.l    #notnull,linelen
  2667.     clr.l    linelensize
  2668.     clr.b    filename
  2669.     rts
  2670.  
  2671. ;in:
  2672. * a0    buffert
  2673. multi_freebuff:
  2674.     pushm    d0-d1/a0-a2/a6
  2675.     move.l    a0,a2
  2676.     base    exec
  2677.  
  2678.  
  2679.     move.l    commessage,d0
  2680.     move.l    d0,a1
  2681.     beq.b    .nomessage
  2682.     move.l    comport,MN_REPLYPORT(a1)
  2683.     move.w    #cm_SIZE,MN_LENGTH(a1)
  2684.     move.w    #cmc_quit,cm_command(a1)
  2685.  
  2686.     move.l    buff_commessageport(a2),d0
  2687.     beq.b    .nomessage
  2688.     move.l    d0,a0
  2689.     move.l    commessage,a1
  2690.     call    PutMsg                ;tell other textread to quit
  2691.  
  2692.     move.l    comport,a0
  2693.     call    WaitPort
  2694. .getallcommsgs
  2695.     move.l    comport,a0
  2696.     call    GetMsg
  2697.     tst.l    d0
  2698.     bne.s    .getallcommsgs
  2699. .nomessage
  2700.     move.l    buff_fileaddr(a2),a1
  2701.     move.l    buff_filememlen(a2),d0
  2702.     beq.B    .nofileinmem
  2703.     call    FreeMem
  2704. .nofileinmem
  2705.     move.l    buff_linelen(a2),a1
  2706.     move.l    buff_linelensize(a2),d0
  2707.     beq.b    .ingetlineminne
  2708.     call    FreeMem
  2709. .ingetlineminne
  2710.     clr.l    buff_fileaddr(a2)
  2711.     clr.l    buff_filelen(a2)
  2712.     clr.l    buff_filememlen(a2)
  2713.     clr.l    buff_linepos(a2)
  2714.     move.l    #1,buff_lines(a2)
  2715.     move.l    #notnull,buff_linelen(a2)
  2716.     clr.l    buff_linelensize(a2)
  2717.     clr.b    buff_filename(a2)
  2718.     popm    d0-d1/a0-a2/a6
  2719.     rts
  2720. multi_freeall:
  2721.     lea    bufflist(pc),a0
  2722.     IFEMPTY    a0,.exit
  2723.     move.l    MLH_HEAD(a0),a0
  2724. .loop
  2725.     tst.l    (a0)
  2726.     beq.b    .exit
  2727.     bsr    multi_freebuff
  2728.     move.l    LN_SUCC(a0),a0
  2729.     bra.b    .loop
  2730. .exit
  2731.     rts
  2732.  
  2733. ;ut:
  2734. * d0    NULL eller buffert.
  2735. multi_addbuff:
  2736.     pushm    d1-d2/a0-a2/a6
  2737.     base    exec
  2738.     move.l    #buff_len,d0
  2739.     move.l    #MEMF_CLEAR!MEMF_ANY,d1
  2740.     call    AllocMem
  2741.     move.l    d0,d2
  2742.     beq.b    .error
  2743.     move.l    d0,a1
  2744.     lea    buff_number(a1),a0
  2745.     move.l    a0,LN_NAME(a1)
  2746.     lea    bufflist(pc),a0
  2747.     call    AddTail
  2748.     move.l    d2,a0
  2749.     clr.l    buff_fileaddr(a0)
  2750.     clr.l    buff_filelen(a0)
  2751.     clr.l    buff_filememlen(a0)
  2752.     clr.l    buff_linepos(a0)
  2753.     move.l    #1,buff_lines(a0)
  2754.     move.l    #notnull,buff_linelen(a0)
  2755.     clr.l    buff_linelensize(a0)
  2756.     clr.b    buff_filename(a0)
  2757.  
  2758. ;default: same settings and -name
  2759.  
  2760.     move.w    #setnamelen-1,d0
  2761.     lea    setname,a1
  2762.     lea    buff_setname(a0),a2
  2763. .copysetname
  2764.     move.b    (a1)+,(a2)+
  2765.     dbf    d0,.copysetname
  2766.  
  2767.     move.w    #settings_len-1,d0
  2768.     lea    settings(pc),a1
  2769.     lea    buff_settings(a0),a2
  2770. .copysettings
  2771.     move.b    (a1)+,(a2)+
  2772.     dbf    d0,.copysettings
  2773.  
  2774.     move.l    a0,d0
  2775.     popm    d1-d2/a0-a2/a6
  2776.     rts
  2777. .error
  2778.     popm    d1-d2/a0-a2/a6
  2779.     moveq    #0,d0
  2780.     rts
  2781.  
  2782. ;in:
  2783. * a0    buffert att ta bort
  2784. multi_rembuff:
  2785.     pushm    d0-d2/a0-a1/a6
  2786.     base    exec
  2787.     move.l    a0,d2
  2788.     move.l    a0,a1
  2789.     call    Remove
  2790.     move.l    d2,a1
  2791.     move.l    #buff_len,d0
  2792.     call    FreeMem
  2793.     popm    d0-d2/a0-a1/a6
  2794.     rts
  2795.  
  2796. multi_remall:
  2797.     pushm    d0-d1/a0-a1/a6
  2798.     base    exec
  2799. .loop
  2800.     lea    bufflist(pc),a0
  2801.     call    RemTail
  2802.     tst.l    d0
  2803.     beq.b    .exit
  2804.     move.l    d0,a1
  2805.     move.l    #buff_len,d0
  2806.     call    FreeMem
  2807.     bra.b    .loop
  2808. .exit
  2809.     popm    d0-d1/a0-a1/a6
  2810.     rts
  2811. ;in:
  2812. * a0    buffert
  2813. ;ut:
  2814. * d0    NULL om ok.
  2815. multi_usebuff:
  2816.     pushm    d1-a6
  2817.  
  2818.     move.w    sysfont(pc),d1
  2819.     move.l    displayid(pc),d2
  2820.     move.l    screendepth(pc),d3
  2821.  
  2822.     bsr    multi_buff2curr
  2823. ; d1,d2,d3..
  2824.     bsr    changeenv
  2825.  
  2826.     popm    d1-a6
  2827.     rts
  2828.  
  2829.  
  2830. ;level 2 (thisbuff must be valid for all but multi_quit)
  2831.  
  2832. ;ut:
  2833. * d0    NULL eller felkod
  2834. multi_new_nochange:
  2835.     pushm    a0
  2836.     move.l    thisbuff(pc),a0
  2837.     bsr    multi_curr2buff
  2838.     bsr    multi_addbuff
  2839.     lea    thisbuff(pc),a0
  2840.     move.l    d0,(a0)
  2841.     beq.b    .error
  2842.     moveq    #0,d0
  2843.     popm    a0
  2844.     rts
  2845. .error
  2846.     moveq    #err_nomem,d0
  2847.     popm    a0
  2848.     rts
  2849. ;ut:
  2850. * d0    NULL eller felkod
  2851. multi_new:
  2852.     pushm    a0
  2853.     move.l    thisbuff(pc),a0
  2854.     bsr    multi_curr2buff
  2855.     bsr    multi_addbuff
  2856.     lea    thisbuff(pc),a0
  2857.     move.l    d0,(a0)
  2858.     beq.b    .error
  2859.     move.l    d0,a0
  2860.     bsr    multi_usebuff
  2861.     popm    a0
  2862.     rts
  2863. .error
  2864.     moveq    #err_nomem,d0
  2865.     popm    a0
  2866.     rts
  2867.  
  2868. ;ut:
  2869. * d0    NULL eller felkod
  2870. multi_close:
  2871.     pushm    a0/a1
  2872.     lea    bufflist(pc),a0
  2873.     move.l    MLH_HEAD(a0),d0
  2874.     cmp.l    MLH_TAILPRED(a0),d0
  2875.     beq.b    .exit            ;don't close last one!
  2876.     move.l    thisbuff(pc),a0
  2877.     move.l    LN_SUCC(a0),a1
  2878.     tst.l    (a1)
  2879.     bne.b    .ok
  2880.     move.l    LN_PRED(a0),a1
  2881. .ok
  2882.     bsr    multi_curr2buff
  2883.     bsr    multi_freebuff
  2884.     bsr    multi_rembuff
  2885.     move.l    a1,a0
  2886.     lea    thisbuff(pc),a1
  2887.     move.l    a0,(a1)
  2888.     bsr    multi_usebuff
  2889. .exit
  2890.     popm    a0/a1
  2891.     rts
  2892.  
  2893. ;in:
  2894. * d0    buffer #
  2895. ;ut:
  2896. * d0    NULL eller felkod
  2897. multi_change:
  2898.     move.l    thisbuff(pc),a0
  2899.     bsr    multi_curr2buff
  2900.     lea    bufflist(pc),a0
  2901. .stepdown
  2902.     TSTNODE    a0,a0
  2903.     beq.b    .error
  2904.     dbf    d0,.stepdown
  2905.     lea    thisbuff(pc),a1
  2906.     move.l    a0,(a1)
  2907.     bsr    multi_usebuff
  2908.     rts
  2909. .error
  2910.     moveq    #0,d0
  2911.     rts
  2912.  
  2913. multi_quit:
  2914.     pushm    d0/a0
  2915.     move.l    thisbuff(pc),a0
  2916.     move.l    a0,d0
  2917.     beq.b    .nocurr
  2918.     bsr    multi_curr2buff
  2919. .nocurr
  2920.     bsr    multi_freeall
  2921.     bsr    multi_remall
  2922.     bsr    multi_clearcurr
  2923.     clr.l    thisbuff
  2924.     popm    d0/a0
  2925.     rts
  2926.  
  2927. ;FIXIT! Countlines may have to be done on some buffers!
  2928. multi_prefs2all:
  2929.     pushm    d0/a0
  2930.  
  2931.     lea    bufflist(pc),a0
  2932.     IFEMPTY    a0,.exit
  2933.     move.l    MLH_HEAD(a0),a0
  2934. .loop
  2935.     tst.l    (a0)
  2936.     beq.b    .exit
  2937.  
  2938.     bsr.b    .copyit
  2939.  
  2940.     move.l    LN_SUCC(a0),a0
  2941.     bra.b    .loop
  2942. .exit
  2943.     popm    d0/a0
  2944.     rts
  2945.  
  2946. .copyit
  2947.     pushm    d0/a1-a2
  2948.     move.w    #prefs2all_len-1,d0
  2949.     lea    prefs2all_start(pc),a1
  2950.     lea    buff_settings+prefs2all_offset(a0),a2
  2951. .copysettings
  2952.     move.b    (a1)+,(a2)+
  2953.     dbf    d0,.copysettings
  2954.     popm    d0/a1-a2
  2955.     rts
  2956.  
  2957. * laddar in filerna i de resterande bufferterna
  2958. ;in:
  2959. * a5    pek till nod i bufflist
  2960. ;ut:
  2961. * d0    0 om ok
  2962. multi_loadrest:
  2963.     pushm    d1-a6
  2964.     bsr    changevideomode
  2965.     tst.l    d0
  2966.     bne.b    .exit
  2967.     lea    tabbar,a0
  2968.     bsr    fixatabbar
  2969.     bra.b    .changed
  2970.  
  2971. .loop
  2972.     tst.l    (a5)
  2973.     beq.b    .listisempty
  2974.  
  2975.     move.l    thisbuff(pc),a0
  2976.     bsr    multi_curr2buff
  2977.     move.l    a5,a0
  2978.     lea    thisbuff(pc),a1
  2979.     move.l    a0,(a1)
  2980.     bsr    multi_usebuff
  2981.     tst.l    d0
  2982.     bne.b    .exit
  2983. .changed
  2984.     lea    filename(pc),a1
  2985.     tst.b    (a1)
  2986.     beq.b    .openreq
  2987.     move.l    #tempsize,d0
  2988.     lea    filereqdir(pc),a0
  2989.     lea    filename(pc),a1
  2990.     lea    temp,a2
  2991.     bsr    pathnfiletobuff
  2992.     move.l    #temp,d0
  2993.     bsr    openfile
  2994.     tst.l    d0
  2995.     beq.b    .nextbuffer
  2996. .openreq
  2997.     pushm    d1-a6
  2998.     bsr    mopen
  2999.     popm    d1-a6
  3000. .nextbuffer
  3001.     move.l    LN_SUCC(a5),a5
  3002.     bra.b    .loop
  3003. .listisempty
  3004.     moveq    #0,d0
  3005. .exit
  3006.     lea    pipeused(pc),a0
  3007.     tst.b    (a0)
  3008.     bne.b    .nopipe
  3009.  
  3010.     pushm    d0
  3011.     base    dos
  3012.     lea    pipename(pc),a0
  3013.     move.l    a0,d1
  3014.     call    DeleteFile
  3015.     popm    d0
  3016. .nopipe
  3017.  
  3018.     popm    d1-a6
  3019.     rts
  3020. thisbuff:
  3021.     dc.l    0
  3022. bufflist:
  3023.     ds.b    MLH_SIZE        ;minimal list header
  3024.  
  3025. **** window locking
  3026.  
  3027. ;    *** nestla inte! ***
  3028. lockwindow:
  3029.     movem.l    d0-d1/a0-a2/a6,-(sp)
  3030.     base    intui
  3031.     lea    lockwinreq,a2
  3032.     move.l    a2,a0
  3033.     call    InitRequester
  3034.     move.l    a2,a0
  3035.     move.l    windowptr(pc),d0
  3036.     beq.b    .nowin
  3037.     move.l    d0,a1
  3038.     call    Request
  3039.     lea    lockwinreqsuccess(pc),a0
  3040.     move.l    d0,(a0)
  3041.     cmp.w    #39,LIB_VERSION(a6)
  3042.     blo.s    .no39
  3043.     move.l    windowptr(pc),a0
  3044.     lea    .tags(pc),a1
  3045.     call    SetWindowPointerA
  3046. .no39
  3047. .nowin
  3048.     movem.l    (sp)+,d0-d1/a0-a2/a6
  3049.     rts
  3050. .tags
  3051.     dc.l    WA_BusyPointer,TRUE
  3052.     dc.l    TAG_DONE
  3053. unlockwindow:
  3054.     movem.l    d0-d1/a0-a1/a6,-(sp)
  3055.     tst.l    lockwinreqsuccess
  3056.     beq.s    .nolock
  3057.     lea    lockwinreqsuccess(pc),a0
  3058.     clr.l    (a0)
  3059.     base    intui
  3060.     lea    lockwinreq,a0
  3061.     move.l    windowptr(pc),d0
  3062.     beq.b    .nowin
  3063.     move.l    d0,a1
  3064.     call    EndRequest
  3065.     cmp.w    #39,LIB_VERSION(a6)
  3066.     blo.s    .no39
  3067.     move.l    windowptr(pc),a0
  3068.     lea    .tags(pc),a1
  3069.     call    SetWindowPointerA
  3070. .no39
  3071. .nolock
  3072. .nowin
  3073.     movem.l    (sp)+,d0-d1/a0-a1/a6
  3074.     rts
  3075. .tags
  3076.     dc.l    WA_BusyPointer,FALSE
  3077.     dc.l    TAG_DONE
  3078. lockwinreqsuccess:
  3079.     dc.l    0
  3080.  
  3081. **** argument parsing
  3082.  
  3083. getargs:
  3084.     lea    boolcli(pc),a0
  3085.     tst.l    (a0)
  3086.     bne.w    ga_cli
  3087. ga_workbench:
  3088.     move.l    argset(pc),a0        ;default prefs
  3089.     bsr.w    loadsettings
  3090.     bsr    prefs2curr
  3091.  
  3092.     move.l    wbmessage(pc),a0
  3093.     move.l    sm_NumArgs(a0),d1
  3094.     move.l    sm_ArgList(a0),a2
  3095.  
  3096. ;in:
  3097. * d1    NumArgs
  3098. * a2    ArgList
  3099. parsewbarg:
  3100.     moveq    #TRUE,d2
  3101.     bsr.b    readargsfromicon
  3102.  
  3103.     add.w    #wa_SIZEOF,a2        ;first project
  3104.     subq.l    #1,d1
  3105. ;in:
  3106. * d1    NumArgs
  3107. * a2    ArgList
  3108. parsewbarg_proj:
  3109.     subq.w    #1,d1
  3110.     bmi.B    .noproject
  3111. .projectloop
  3112.     move.l    wa_Name(a2),a0
  3113.     tst.b    (a0)
  3114.     beq.b    .nofile
  3115.     moveq    #FALSE,d2
  3116.     bsr.b    readargsfromicon
  3117.     bra.b    .nodir
  3118. .nofile
  3119.     bsr.b    .wasdiricon
  3120. .nodir
  3121.     tst.l    d1            ;last file?
  3122.     beq.b    .noproject
  3123.     tst.l    d0            ;was it prefs?
  3124.     bne.b    .nextproject
  3125.     bsr    multi_new_nochange
  3126.     tst.l    d0
  3127.     bne.b    .noproject
  3128. .nextproject
  3129.     add.w    #wa_SIZEOF,a2        ;next project
  3130.     dbf    d1,.projectloop
  3131. .noproject
  3132.     move.l    thisbuff(pc),a0
  3133.     bsr    multi_curr2buff        ;save last buffer
  3134.  
  3135.     moveq    #0,d0
  3136.     rts
  3137. .wasdiricon
  3138.     pushm    d1-d3/a0-a3
  3139.     base    dos
  3140.     move.l    wa_Lock(a2),d1
  3141.     lea    filereqdir(pc),a0
  3142.     move.l    a0,d2
  3143.     move.l    #256,d3
  3144.     call    NameFromLock
  3145.     clr.b    filename
  3146.     moveq    #FALSE,d0        ;no prefs file
  3147.     popm    d1-d3/a0-a3
  3148.     rts
  3149.  
  3150. ;in:
  3151. * a2    pek till WBArg   (eller: dc.l lock : dc.l name)
  3152. * d2    TRUE=denna fil ska _inte_ laddas in (rör inte filename, filereqpath)
  3153. ;ut:
  3154. * d0    TRUE om filen var en prefsfil
  3155. readargsfromicon:
  3156.     pushm    d1-a6
  3157.  
  3158.     moveq    #FALSE,d5
  3159.  
  3160.     bsr.w    .loadicon
  3161.     tst.l    d0
  3162.     beq.w    .filewithouticon
  3163.     base    icon
  3164.     move.l    d0,a0
  3165.     move.l    do_ToolTypes(a0),a2
  3166.  
  3167.     move.l    a2,a0
  3168.     lea    .filetype(pc),a1
  3169.     call    FindToolType
  3170.     tst.l    d0
  3171.     beq.b    .nofiletype
  3172.     move.l    d0,a0
  3173.     lea    .prefs(pc),a1
  3174.     call    MatchToolValue
  3175.     tst.l    d0
  3176.     beq.b    .notprefs
  3177.  
  3178.     moveq    #TRUE,d5
  3179.     lea    argprojectname,a0
  3180.     bsr.w    loadsettings        ;load prefs file first
  3181.     bsr    prefs2curr
  3182.     bra.b    .skipload
  3183. .notprefs
  3184. .nofiletype
  3185.     move.l    a2,a0
  3186.     lea    .settings(pc),a1
  3187.     call    FindToolType
  3188.     tst.l    d0
  3189.     beq.b    .nosettings
  3190.     move.l    d0,a0
  3191.  
  3192.     bsr.w    loadsettings        ;load prefs file first
  3193.     bsr    prefs2curr
  3194. .nosettings
  3195. ;om man kommer hit var filen i fråga inte nån prefsfil, dvs denna ska vi
  3196. ;ladda in
  3197.     tst.l    d2
  3198.     bne.b    .skipload
  3199.     move.l    #argprojectname,d2
  3200.     moveq    #0,d0            ;wb has always full path!
  3201.     bsr    splitfilepath
  3202. .skipload
  3203.  
  3204.     move.l    a2,a0
  3205.     lea    .new(pc),a1
  3206.     call    FindToolType
  3207.     tst.l    d0
  3208.     beq.b    .nonew
  3209.     lea    argnew(pc),a0
  3210.     move.l    #1,(a0)
  3211. .nonew
  3212.     move.l    a2,a0
  3213.     lea    .tabs(pc),a1
  3214.     call    FindToolType
  3215.     tst.l    d0
  3216.     beq.b    .notabs
  3217.     move.l    d0,d1
  3218.     lea    .tabsize(pc),a0
  3219.     move.l    a0,d2
  3220.     base    dos
  3221.     call    StrToLong
  3222.     cmp.l    #-1,d0
  3223.     beq.b    .notabs
  3224.     lea    tabsize(pc),a0
  3225.     lea    .tabsize(pc),a1
  3226.     move.l    (a1),(a0)
  3227. .notabs
  3228.     base    icon
  3229.     move.l    a2,a0
  3230.     lea    .unit(pc),a1
  3231.     call    FindToolType
  3232.     tst.l    d0
  3233.     beq.b    .nounit
  3234.     move.l    d0,d1
  3235.     lea    .unittmp(pc),a0
  3236.     move.l    a0,d2
  3237.     base    dos
  3238.     call    StrToLong
  3239.     cmp.l    #-1,d0
  3240.     beq.b    .nounit
  3241.     lea    unit(pc),a0
  3242.     lea    .unittmp(pc),a1
  3243.     move.l    a1,(a0)
  3244. .nounit
  3245. .freediskobj
  3246.     base    icon
  3247.     move.l    wbdiskobj(pc),d0
  3248.     beq.b    .noicon
  3249.     move.l    d0,a0
  3250.     call    FreeDiskObject
  3251.     lea    wbdiskobj(pc),a0
  3252.     clr.l    (a0)
  3253. .noicon
  3254.     move.l    d5,d0
  3255.     popm    d1-a6
  3256.     rts
  3257. .filewithouticon
  3258.     tst.l    d2
  3259.     bne.b    .freediskobj
  3260.     move.l    #argprojectname,d2
  3261.     moveq    #0,d0            ;wb has always full path!
  3262.     bsr    splitfilepath
  3263.     bra.b    .freediskobj
  3264.  
  3265. .tabsize    dc.l    0
  3266. .unittmp        dc.l    0
  3267. ;in:
  3268. * a2    pek till WBArg   (eller: dc.l lock : dc.l name)
  3269. ;ut:
  3270. * d0    pek till diskobj eller 0 om fel
  3271. .loadicon
  3272.     pushm    d1-d3/a0
  3273.     base    dos
  3274.     move.l    (a2),d1
  3275.     move.l    #argprojectname,d2
  3276.     move.l    #256,d3
  3277.     call    NameFromLock
  3278.     tst.l    d0
  3279.     beq.b    .li_error
  3280.     move.l    d2,d1
  3281.     move.l    4(a2),d2
  3282.     move.l    #256,d3
  3283.     call    AddPart
  3284.     tst.l    d0
  3285.     beq.b    .li_error
  3286.     base    icon
  3287.     lea    argprojectname,a0
  3288.     call    GetDiskObject
  3289.     lea    wbdiskobj(pc),a0
  3290.     move.l    d0,(a0)
  3291. .li_error
  3292.     popm    d1-d3/a0
  3293.     rts
  3294. .filetype    dc.b    "FILETYPE",0
  3295. .prefs        dc.b    "PREFS",0
  3296. .tabs        dc.b    "TABS",0
  3297. .new        dc.b    "NEW",0
  3298. .unit        dc.b    "UNIT",0
  3299. .settings    dc.b    "SETTINGS",0
  3300.     even
  3301. ga_cli:
  3302.     base    dos
  3303.     lea    ga_template(pc),a0
  3304.     move.l    a0,d1
  3305.     lea    args(pc),a0
  3306.     move.l    a0,d2
  3307.     moveq    #0,d3
  3308.     call    ReadArgs
  3309.     move.l    d0,rastruct
  3310.     bne.b    .ok
  3311. .show
  3312.     lea    ga_usage(pc),a0
  3313.     move.l    a0,d1
  3314.     call    PutStr
  3315.     moveq    #err_exitnow,d0
  3316.     rts
  3317. .ok
  3318.     move.l    argset(pc),a0
  3319.     bsr.w    loadsettings        ;load prefs file first
  3320.     bsr    prefs2curr
  3321.  
  3322.     move.l    argunit(pc),a0
  3323.     lea    unit(pc),a1
  3324.     move.l    (a0),(a1)
  3325.  
  3326.     move.l    argtab(pc),a0
  3327.     lea    tabsize(pc),a1
  3328.     move.l    (a0),(a1)
  3329.  
  3330.     base    dos
  3331.     call    Input
  3332.     move.l    d0,d4
  3333.     beq.w    .noinputfile
  3334.     move.l    d4,d1
  3335.     call    IsInteractive
  3336.     tst.l    d0            ;Interactive (= no file redirection)?
  3337.     bne.w    .noinputfile        ;Yes, skip
  3338.  
  3339.     move.l    d4,d1
  3340.     move.l    #temp,d2
  3341.     move.l    #tempsize,d3
  3342.     call    NameFromFH
  3343.     tst.l    d0
  3344.     beq.b    .pipe
  3345.  
  3346. ;Standard redirection: Filename & size known!
  3347.  
  3348.     moveq    #0,d0
  3349.     move.l    #temp,d2
  3350.     bsr    splitfilepath
  3351.     bra.w    parsefilenamearray\.exit
  3352.  
  3353. ;Pipe: Unknown name, unknown size :-(
  3354.  
  3355. .pipe
  3356. .1    ;ASMONE BUG :(
  3357.  
  3358.     base    util
  3359.     cmp.w    #39,LIB_VERSION(a6)
  3360.     blo.s    .nov39
  3361.     call    GetUniqueID
  3362.     bra.b    .uniqueidok
  3363. .nov39
  3364.     move.l    thistask(pc),d0
  3365. .uniqueidok
  3366.     bsr    numdec
  3367.     move.l    d0,a0
  3368.     lea    pipenamenum(pc),a1
  3369. .copynum    
  3370.     move.b    (a0)+,(a1)+
  3371.     bne.b    .copynum
  3372.  
  3373.     base    exec
  3374.     move.l    #1024,d0
  3375.     moveq    #MEMF_ANY,d1
  3376.     call    AllocVec
  3377.     move.l    d0,d6
  3378.     beq.w    .nomem
  3379.     base    dos
  3380.     lea    pipename(pc),a0
  3381.     move.l    a0,d1
  3382.     move.l    #MODE_NEWFILE,d2
  3383.     call    Open
  3384.     move.l    d0,d5
  3385.     beq.b    .nooutputfile
  3386.  
  3387.     move.l    d4,d1
  3388.     move.l    d6,d2
  3389.     move.l    #1024,d3
  3390.     call    Read
  3391.     move.l    d0,d3
  3392.     beq.b    .error            ;EOF on first read => run (for example)
  3393.     addq.l    #1,d0
  3394.     beq.b    .error
  3395.  
  3396. .copyfile
  3397.     move.l    d5,d1
  3398.     move.l    d6,d2
  3399.     call    Write
  3400.     addq.l    #1,d0
  3401.     beq.b    .error
  3402.  
  3403.     move.l    d4,d1
  3404.     move.l    d6,d2
  3405.     move.l    #1024,d3
  3406.     call    Read
  3407.     move.l    d0,d3
  3408.     beq.b    .eof
  3409.     addq.l    #1,d0
  3410.     bne.b    .copyfile
  3411.  
  3412. .eof
  3413.  
  3414.     lea    argnames(pc),a1
  3415.     lea    pipeargnames(pc),a0
  3416.     move.l    a0,(a1)
  3417. .error
  3418.     lea    pipeused(pc),a0        ;mark file to be deleted
  3419.     clr.b    (a0)
  3420.  
  3421.     base    dos
  3422.     move.l    d5,d1
  3423.     call    Close
  3424.  
  3425. .nooutputfile
  3426.     base    exec
  3427.     move.l    d6,a1
  3428.     call    FreeVec
  3429. .nomem
  3430.  
  3431.  
  3432. .noinputfile
  3433.  
  3434.  
  3435. ; gå igenom alla filnamn som angavs, skapa en ny buffer för var och en
  3436. ; av dom (utom den första).
  3437.  
  3438.     move.l    argnames(pc),a2
  3439.     moveq    #0,d0            ;currentdir is ok
  3440.  
  3441. ;in:
  3442. * d0    currentdir (string) eller 0
  3443. * a2    array med pek till filnamn/dirs
  3444.  
  3445. parsefilenamearray:
  3446.     move.l    d0,.currentdir
  3447.     cmp.l    #0,a2
  3448.     beq.b    .exit
  3449. .copynextname
  3450.     move.l    (a2)+,d2
  3451.     beq.b    .exit
  3452.  
  3453.     move.l    .currentdir(pc),d0
  3454.     bsr    splitfilepath
  3455.  
  3456.     tst.l    (a2)
  3457.     beq.b    .exit
  3458.     bsr    multi_new_nochange
  3459.     tst.l    d0
  3460.     beq.b    .copynextname
  3461. .exit
  3462.     move.l    thisbuff(pc),a0
  3463.     bsr    multi_curr2buff        ;save last buffer
  3464.     moveq    #0,d0
  3465.     rts
  3466. .currentdir
  3467.     dc.l    0
  3468. ga_template:
  3469.     dc.b    "FILES/M,TABS/K/N,UNIT/K/N,SETTINGS/K,NEW/S",0
  3470. ;FIXIT! Localize it!
  3471. ga_usage:
  3472.     dc.b    27,"[1mTextread "
  3473.     releasestr
  3474.     dc.b    27,"[22m ©1992-1995 Martin Blom.",10
  3475.     dc.b    "Usage: Textread [[FILES] <files|dirs>] [TABS <n>] [UNIT <n>]",10
  3476.     dc.b    "                [SETTINGS <name>] [NEW]",10,0
  3477.     even
  3478. ;FIXIT! kommentarer => engelska
  3479. args:
  3480. argnames:    dc.l    null        ;pek till lista med filnamn
  3481. argtab:        dc.l    tabsize        ;pek till lw med tab
  3482. argunit:    dc.l    null        ;pek till lw med unit
  3483. argset:        dc.l    defsetname    ;pek till settingsnamn
  3484. argnew:        dc.l    0        ;0 eller inte 0
  3485. * ^^^ fylls i av readargs
  3486. argdir:        dc.l    null        ;pek till dirnamn
  3487.  
  3488. boolcli:    dc.l    1
  3489. wbmessage:    dc.l    0
  3490. wbdiskobj:    dc.l    0
  3491. rastruct:    dc.l    0
  3492.  
  3493. pipeargnames:    dc.l    pipename,0
  3494. pipeused:    dc.b    1        ;0=pipe, 1=no pipe
  3495. pipename:    dc.b    "T:TextreadPipe"
  3496. pipenamenum:    dc.b    "0000000000",0
  3497.  
  3498. **** file names
  3499.  
  3500. ;in:
  3501. * d0    currentdir (lock) eller 0
  3502. * d2    filnamn med path
  3503. ;ut:
  3504. * filename & filereqdir ifyllt med inga relativa sökvägar kvar
  3505. splitfilepath:
  3506.     pushm    d0-d3/a0-a1/a6
  3507.     base    dos
  3508.     move.l    d2,.filename
  3509.     clr.l    .currentdir
  3510.     move.l    d0,d1
  3511.     beq.b    .nocurrdir
  3512.     call    CurrentDir
  3513.     move.l    d0,.currentdir
  3514. .nocurrdir
  3515.     move.l    .filename(pc),d1
  3516.     moveq    #ACCESS_READ,d2
  3517.     call    Lock                ;för att expandera pathen
  3518.     move.l    d0,.lock
  3519.     bne.b    .lockedfile
  3520.     move.l    .filename(pc),d1
  3521.     bra.b    .splitit            ;ta det namnet som skrevs!
  3522. .lockedfile
  3523.     clr.l    fib+fib_DirEntryType
  3524.     move.l    .lock,d1
  3525.     move.l    #fib,d2
  3526.     call    Examine                ;skit i resultatet
  3527.  
  3528.     move.l    .lock(pc),d1
  3529.     move.l    #temp,d2
  3530.     move.l    #tempsize,d3
  3531.     call    NameFromLock
  3532.     move.l    .lock(pc),d1
  3533.     call    UnLock
  3534.     tst.l    fib+fib_DirEntryType
  3535.     bmi.b    .wasfile
  3536.     clr.b    filename        
  3537.     move.l    .filename(pc),a0
  3538.     bra.b    .copydir
  3539. .wasfile
  3540.     move.l    #temp,d1
  3541. .splitit
  3542.     move.l    d1,d2        ;->
  3543.     call    FilePart
  3544.     move.l    d0,a0
  3545.     lea    filename(pc),a1
  3546.     moveq    #31,d0
  3547. .copynameloop
  3548.     move.b    (a0)+,(a1)+
  3549.     dbeq    d0,.copynameloop
  3550.  
  3551.     move.l    d2,d1        ;<-
  3552.     call    PathPart
  3553.     move.l    d0,a0
  3554.     clr.b    (a0)        ;klipp bort filnamnet
  3555.     move.l    d2,a0        ;<-
  3556. .copydir
  3557.     lea    filereqdir(pc),a1
  3558.     move.w    #255,d0
  3559. .copydirloop
  3560.     move.b    (a0)+,(a1)+
  3561.     dbeq    d0,.copydirloop
  3562. .exit
  3563.     move.l    .currentdir,d1
  3564.     beq.b    .nocurrdir2
  3565.     call    CurrentDir    ;återställ!
  3566. .nocurrdir2
  3567.     popm    d0-d3/a0-a1/a6
  3568.     rts
  3569. .lock    dc.l    0
  3570. .currentdir
  3571.     dc.l    0
  3572. .filename
  3573.     dc.l    0
  3574. ;in:
  3575. * d0    buffertlängd
  3576. * a0    path
  3577. * a1    filnamn
  3578. * a2    buffert
  3579. pathnfiletobuff:
  3580.     base    dos
  3581.     move.l    a2,d1
  3582.     move.l    a1,d2
  3583.     move.l    d0,d3
  3584.     subq.w    #1,d0
  3585. .copydir
  3586.     move.b    (a0)+,(a2)+
  3587.     dbf    d0,.copydir
  3588.     call    AddPart
  3589.     tst.l    d0
  3590.     beq.b    .exit
  3591.     moveq    #0,d0
  3592.     rts
  3593. .exit
  3594.     moveq    #-1,d0
  3595.     rts
  3596.  
  3597. **** buffer movements
  3598.  
  3599. ;in:
  3600. * d0    gå till rad (0-?)
  3601. ;ut:
  3602. * d0    rader att printa-1
  3603. * a0    adress till rad
  3604. gotoline:
  3605.     movem.l    d1-d2/a1,-(sp)
  3606.     move.l    .thisline(pc),d1
  3607.     move.l    d1,d2
  3608.     lea    .thisline(pc),a0
  3609.     move.l    d0,(a0)
  3610.     move.l    fileaddr(pc),a0
  3611.     move.l    linelen(pc),a1
  3612.     sub.l    d0,d1
  3613.     bmi.b    .minus
  3614.     cmp.l    d0,d1
  3615.     bhs.b    .beginning
  3616.  
  3617.     add.l    d2,a1            ;<-- curr
  3618.     move.l    .thisaddr(pc),a0
  3619.     move.l    d1,d0
  3620.     subq.l    #1,d0
  3621.     bmi.b    .ok
  3622.     moveq    #0,d1
  3623. .loop1
  3624.     move.b    -(a1),d1
  3625.     addq.w    #1,d1
  3626.     sub.w    d1,a0
  3627.     dbf    d0,.loop1
  3628.     bra.b    .ok
  3629. .minus
  3630.     neg.l    d1
  3631.     cmp.l    d0,d1
  3632.     bhs.b    .beginning
  3633.     add.l    d2,a1            ;curr -->
  3634.     move.l    .thisaddr(pc),a0
  3635.     move.l    d1,d0
  3636. .beginning
  3637.     subq.l    #1,d0
  3638.     bmi.b    .ok
  3639.     moveq    #0,d1
  3640. .loop
  3641.     move.b    (a1)+,d1
  3642.     addq.w    #1,d1
  3643.     add.w    d1,a0
  3644.     dbf    d0,.loop
  3645. .ok
  3646.     lea    .thisaddr(pc),a1
  3647.     move.l    a0,(a1)
  3648.     move.l    lines(pc),d0
  3649.     sub.l    .thisline(pc),d0
  3650.     cmp.l    cheight(pc),d0
  3651.     ble.b    .ok2
  3652.     move.l    cheight(pc),d0
  3653. .ok2
  3654.     movem.l    (sp)+,d1-d2/a1
  3655.     rts
  3656. .thisaddr    dc.l    0
  3657. .thisline    dc.l    1
  3658.  
  3659.  
  3660. ;in:
  3661. * a0    adress
  3662. ;ut:
  3663. * d0    rad som a0 var på
  3664. getline:
  3665.     pushm    d1/a0-a2
  3666.     move.l    fileaddr(pc),a1
  3667.     move.l    linelen(pc),a2
  3668.     moveq    #0,d0
  3669. .loop
  3670.     cmp.l    a0,a1
  3671.     bhi.b    .ok        ;om passerat
  3672.     move.b    (a2)+,d1
  3673.     addq.w    #1,d1
  3674.     add.w    d1,a1
  3675.     addq.l    #1,d0
  3676.     bra.b    .loop
  3677. .ok
  3678.     popm    d1/a0-a2
  3679.     rts
  3680.  
  3681. gotop:
  3682.     lea    linepos(pc),a0
  3683.     tst.l    (a0)
  3684.     beq.b    .exit
  3685.     clr.l    (a0)
  3686.     bra.w    textredraw
  3687. .exit
  3688.     rts
  3689. gobottom:
  3690.     lea    linepos(pc),a0
  3691.     move.l    lines(pc),d0
  3692.     sub.l    cheight(pc),d0
  3693.     bpl.b    .ok
  3694.     moveq    #0,d0
  3695. .ok
  3696.     cmp.l    (a0),d0
  3697.     beq.b    .exit
  3698.     move.l    d0,(a0)
  3699.     bra.w    textredraw
  3700. .exit
  3701.     rts
  3702. prevpage:
  3703.     lea    linepos(pc),a0
  3704.     move.l    (a0),d0
  3705.     bne.b    .ok1        ;redan 0 ?
  3706.     moveq    #0,d0
  3707.     rts
  3708. .ok1
  3709.     sub.l    cheight(pc),d0
  3710.     addq.l    #1,d0
  3711.     bpl.b    .ok
  3712.     moveq    #0,d0
  3713. .ok
  3714.     move.l    d0,(a0)
  3715.     bra.w    textredraw
  3716.  
  3717. nextpage:
  3718.     lea    linepos(pc),a0
  3719.     move.l    (a0),d0
  3720.     move.l    d0,d7
  3721.     add.l    cheight(pc),d0
  3722.     subq.l    #1,d0
  3723.     move.l    d0,(a0)
  3724.     bsr.w    fixlinepos
  3725.     cmp.l    linepos(pc),d7
  3726.     bne.b    .ok
  3727.     moveq    #0,d0
  3728.     rts
  3729. .ok
  3730.     bra.w    textredraw
  3731.  
  3732.  
  3733. prevpagescroll:
  3734.     move.l    fonty(pc),d0
  3735.     move.l    cheight(pc),d1
  3736.     subq.l    #1,d1
  3737.     bra.w    scrolldown
  3738.  
  3739. nextpagescroll:
  3740.     move.l    fonty(pc),d0
  3741.     move.l    cheight(pc),d1
  3742.     subq.l    #1,d1
  3743.     bra.w    scrollup
  3744.  
  3745. prevpage3:
  3746.     lea    linepos(pc),a0
  3747.     move.l    (a0),d0
  3748.     bne.b    .ok1        ;redan 0 ?
  3749.     moveq    #0,d0
  3750.     rts
  3751. .ok1
  3752.     move.l    cheight(pc),d1
  3753.     mulu.w    #3,d1
  3754.     sub.l    d1,d0
  3755.     bpl.b    .ok
  3756.     moveq    #0,d0
  3757. .ok
  3758.     move.l    d0,(a0)
  3759.     bra.w    textredraw
  3760. nextpage3:
  3761.     lea    linepos(pc),a0
  3762.     move.l    (a0),d0
  3763.     move.l    d0,d7
  3764.     move.l    cheight(pc),d1
  3765.     mulu.w    #3,d1
  3766.     add.l    d1,d0
  3767.     move.l    d0,(a0)
  3768.     bsr.w    fixlinepos
  3769.     cmp.l    linepos(pc),d7
  3770.     bne.b    .ok
  3771.     moveq    #0,d0
  3772.     rts
  3773. .ok
  3774.     bra.w    textredraw
  3775.  
  3776. ;in:
  3777. * d0.w    speed (-4, -3, -2, -1, 0, 1, 2, 3 ,4  0=inget)
  3778. scrollsmooth:
  3779.     ext.l    d0
  3780.     tst.l    d0
  3781.     beq.s    .exit
  3782.     bpl.s    .plus
  3783.     neg.l    d0
  3784.     subq.l    #1,d0
  3785.     moveq    #1,d1
  3786.     lsl.l    d0,d1
  3787.     move.l    d1,d0
  3788.     moveq    #1,d1
  3789.     bra.w    scrolldown
  3790. .plus
  3791.     subq.l    #1,d0
  3792.     moveq    #1,d1
  3793.     lsl.l    d0,d1
  3794.     move.l    d1,d0
  3795.     moveq    #1,d1
  3796.     bra    scrollup
  3797. .exit
  3798.     moveq    #0,d0
  3799.     rts
  3800.  
  3801. scrollup1:
  3802.     move.l    fonty(pc),d0
  3803.     moveq    #1,d1
  3804. scrollup:
  3805.     bsr.b    scrollup_noupdate
  3806.     bsr.w    changescroll
  3807.     moveq    #0,d0
  3808.     rts
  3809. ;in:
  3810. * d0    (Pixel)Lines/Frame (1,2,3,...,fonty,fonty*2,fonty*3,...)
  3811. * d1    Repeat times
  3812. scrollup_noupdate:
  3813.     move.l    d0,.speed
  3814.     move.w    d1,.repeat
  3815.  
  3816.     base    exec
  3817.     move.l    intsignal(pc),d1
  3818.     moveq    #0,d0
  3819.     bset    d1,d0
  3820.     move.l    thistask(pc),a1
  3821.     call    Signal            ;gör en ny signal direkt!
  3822.  
  3823. .nextpass
  3824.     move.l    .speed,d0
  3825.     add.l    fonty(pc),d0
  3826.     subq.l    #1,d0
  3827.     divu.w    fonty+2(pc),d0
  3828.     and.l    #$ffff,d0
  3829.     lea    linepos(pc),a0
  3830.     move.l    (a0),-(sp)
  3831.     add.l    d0,(a0)
  3832.     bsr.w    fixlinepos
  3833.     move.l    (sp)+,d0
  3834.     sub.l    linepos(pc),d0
  3835.     neg.l    d0
  3836.     beq    .exit
  3837.  
  3838.     move.l    fonty(pc),d1
  3839.     cmp.l    .speed(pc),d1
  3840.     bhi.b    .softscroll
  3841.  
  3842.     mulu.w    fonty+2(pc),d0
  3843.     move.l    d0,.speed
  3844.     move.w    #1,.cnt
  3845.     bra.b    .scroll_loop
  3846.  
  3847. .softscroll
  3848.     move.l    fonty(pc),d1
  3849.     divu.w    .speed+2(pc),d1
  3850.     move.w    d1,.cnt
  3851.  
  3852.     move.l    .speed(pc),-(sp)            ;prescroll
  3853.     swap.w    d1
  3854.     move.w    d1,.speed+2
  3855.     beq.b    .noprescroll
  3856.     bsr     .scrollup_and_clear
  3857. .noprescroll
  3858.     move.l    (sp)+,.speed
  3859.  
  3860. .scroll_loop
  3861.     base    exec
  3862.     moveq    #0,d0
  3863.     move.l    intsignal(pc),d1
  3864.     bset    d1,d0
  3865.     call    Wait
  3866.  
  3867.     bsr    .scrollup_and_clear
  3868.  
  3869.     lea    .cnt(pc),a0
  3870.     subq.w    #1,(a0)
  3871.     bne.s    .scroll_loop
  3872.  
  3873.     move.l    .speed(pc),d5
  3874.     add.l    fonty(pc),d5
  3875.     subq.l    #1,d5
  3876.     divu.w    fonty+2(pc),d5
  3877.     and.l    #$ffff,d5
  3878.  
  3879. .printbottom
  3880.     move.l    linepos(pc),d0
  3881.     add.l    cheight(pc),d0
  3882.     sub.l    d5,d0
  3883.     move.l    linelen(pc),a0
  3884.     moveq    #0,d3
  3885.     move.b    (a0,d0.l),d3
  3886.     bsr.w    gotoline
  3887.     cmp.b    #$ff,d3
  3888.     beq.b    .skipline
  3889.     moveq    #0,d1
  3890.     move.l    cheight(pc),d2
  3891.     sub.l    d5,d2
  3892.     bsr.w    print
  3893. .skipline
  3894.     subq.l    #1,d5
  3895.     bne.b    .printbottom
  3896.  
  3897.     lea    .repeat(pc),a0
  3898.     subq.w    #1,(a0)
  3899.     bne.w    .nextpass
  3900. .exit
  3901.     bsr.w    changenum
  3902.     moveq    #0,d0
  3903.     rts
  3904. .speed    dc.l    0
  3905. .repeat    dc.w    0
  3906. .cnt    dc.w    0
  3907.  
  3908. .scrollup_and_clear
  3909.     base    gfx
  3910.  
  3911.     tst.w    legalprint
  3912.     bne.w    .system
  3913.  
  3914.     call    OwnBlitter
  3915.     call    WaitBlit
  3916.     lea    $dff000,a5
  3917.  
  3918.     move.l    #$09f00000,bltcon0(a5)
  3919.     move.l    #-1,bltafwm(a5)
  3920.     move.l    plane0(pc),d0
  3921.     move.l    .speed(pc),d1
  3922.     mulu.w    bwidth+2(pc),d1
  3923.     move.l    d0,bltdpt(a5)
  3924.     add.l    d1,d0
  3925.     move.l    d0,bltapt(a5)
  3926.     move.w    #0,bltamod(a5)
  3927.     move.w    #0,bltdmod(a5)
  3928.     move.l    bwidth(pc),d0
  3929.     lsr.l    #1,d0
  3930.     move.l    cheightp(pc),d1
  3931.     sub.l    .speed(pc),d1
  3932.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  3933.     bne.b    .bigblit1
  3934.     lsl.l    #6,d1
  3935.     or.l    d0,d1
  3936.     move.w    d1,bltsize(a5)
  3937.     bra.b    .blitted1
  3938. .bigblit1
  3939.     move.w    d1,bltsizv(a5)
  3940.     move.w    d0,bltsizh(a5)
  3941. .blitted1
  3942.     call    WaitBlit
  3943.     move.l    #$01000000,bltcon0(a5)
  3944.     move.l    #-1,bltafwm(a5)
  3945.     move.l    cheightp(pc),d0
  3946.     sub.l    .speed(pc),d0
  3947.     mulu.w    bwidth+2(pc),d0
  3948.     add.l    plane0(pc),d0
  3949.     move.l    d0,bltdpt(a5)
  3950.     move.w    #0,bltdmod(a5)
  3951.  
  3952.     move.l    bwidth(pc),d0
  3953.     lsr.l    #1,d0
  3954.     move.l    .speed(pc),d1
  3955.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  3956.     bne.b    .bigblit2
  3957.     lsl.l    #6,d1
  3958.     or.l    d0,d1
  3959.     move.w    d1,bltsize(a5)
  3960.     bra.b    .blitted2
  3961. .bigblit2
  3962.     move.w    d1,bltsizv(a5)
  3963.     move.w    d0,bltsizh(a5)
  3964. .blitted2
  3965.     call    DisownBlitter
  3966.     call    WaitBlit
  3967.     rts
  3968. .system
  3969.     move.l    screenptr(pc),a3
  3970.     lea    sc_RastPort(a3),a3
  3971.     move.l    rp_BitMap(a3),a0
  3972.  
  3973.     move.l    .speed(pc),d0
  3974.     move.l    a0,a1
  3975.     suba.l    a2,a2
  3976.     move.l    d0,d1
  3977.     add.l    barheight(pc),d1
  3978.     moveq    #0,d2
  3979.     move.l    d1,d3
  3980.     sub.l    d0,d3
  3981.     move.l    cwidthp(pc),d4
  3982.     move.l    cheightp(pc),d5
  3983.     sub.l    d0,d5
  3984.     move.w    #$c0,d6
  3985.     moveq    #1,d7
  3986.     moveq    #0,d0
  3987.     call    BltBitMap
  3988.  
  3989.     
  3990.     move.l    a3,a1
  3991.     moveq    #0,d0
  3992.     call    SetAPen
  3993.     move.l    a3,a1
  3994.     moveq    #0,d0
  3995.     move.l    cheightp(pc),d1
  3996.     add.l    barheight(pc),d1
  3997.     sub.l    .speed(pc),d1
  3998.     move.l    cwidthp(pc),d2
  3999.     move.l    d1,d3
  4000.     add.l    .speed(pc),d3
  4001.     subq.l    #1,d3
  4002.     call    RectFill
  4003.     rts
  4004.  
  4005. scrolldown1:
  4006.     move.l    fonty(pc),d0
  4007.     moveq    #1,d1
  4008. scrolldown:
  4009.     bsr.b    scrolldown_noupdate
  4010.     bsr.w    changescroll
  4011.     moveq    #0,d0
  4012.     rts
  4013. ;in:
  4014. * d0    (Pixel)Lines/Frame (1,2,4,8,16,24,32,40,...)
  4015. * d1    Repeat times
  4016. scrolldown_noupdate:
  4017.     move.l    d0,.speed
  4018.     move.w    d1,.repeat
  4019.  
  4020.     base    exec
  4021.     move.l    intsignal(pc),d1
  4022.     moveq    #0,d0
  4023.     bset    d1,d0
  4024.     move.l    thistask(pc),a1
  4025.     call    Signal            ;gör en ny signal direkt!
  4026.  
  4027. .nextpass
  4028.     move.l    .speed,d0
  4029.     add.l    fonty(pc),d0
  4030.     subq.l    #1,d0
  4031.     divu.w    fonty+2(pc),d0
  4032.     and.l    #$ffff,d0
  4033.     lea    linepos(pc),a0
  4034.     sub.l    d0,(a0)
  4035.     bpl.s    .notbeg
  4036.     move.l    (a0),d1
  4037.     clr.l    (a0)
  4038.     add.l    d1,d0
  4039.     beq.w    .exit
  4040. .notbeg
  4041.     move.l    fonty(pc),d1
  4042.     cmp.l    .speed(pc),d1
  4043.     bhi.b    .softscroll
  4044.  
  4045.     mulu.w    fonty+2(pc),d0
  4046.     move.l    d0,.speed
  4047.     move.w    #1,.cnt
  4048.     bra.b    .scroll_loop
  4049.  
  4050. .softscroll
  4051.     move.l    fonty(pc),d1
  4052.     divu.w    .speed+2(pc),d1
  4053.     move.w    d1,.cnt
  4054.  
  4055.     move.l    .speed(pc),-(sp)            ;prescroll
  4056.     swap.w    d1
  4057.     move.w    d1,.speed+2
  4058.     beq.b    .noprescroll
  4059.     bsr     .scrolldown_and_clear
  4060. .noprescroll
  4061.     move.l    (sp)+,.speed
  4062.  
  4063. .scroll_loop
  4064.     base    exec
  4065.     moveq    #0,d0
  4066.     move.l    intsignal(pc),d1
  4067.     bset    d1,d0
  4068.     call    Wait
  4069.  
  4070.     bsr    .scrolldown_and_clear
  4071.  
  4072.     lea    .cnt(pc),a0
  4073.     subq.w    #1,(a0)
  4074.     bne.s    .scroll_loop
  4075.  
  4076.     move.l    .speed(pc),d5
  4077.     add.l    fonty(pc),d5
  4078.     subq.l    #1,d5
  4079.     divu.w    fonty+2(pc),d5
  4080.     subq.l    #1,d5
  4081.     and.l    #$ffff,d5
  4082. .printtop
  4083.     move.l    linepos(pc),d0
  4084.     add.l    d5,d0
  4085.     move.l    linelen(pc),a0
  4086.     moveq    #0,d3
  4087.     move.b    (a0,d0.l),d3
  4088.     bsr.w    gotoline
  4089.     cmp.b    #$ff,d3
  4090.     beq.w    .skipline
  4091.     moveq    #0,d1
  4092.     move.l    d5,d2
  4093.     bsr.w    print
  4094. .skipline
  4095.     dbf    d5,.printtop
  4096.  
  4097.     lea    .repeat(pc),a0
  4098.     subq.w    #1,(a0)
  4099.     bne.w    .nextpass
  4100. .exit
  4101.     bsr.w    changenum
  4102.     moveq    #0,d0
  4103.     rts
  4104. .speed    dc.l    0
  4105. .repeat    dc.w    0
  4106. .cnt    dc.w    0
  4107.  
  4108. .scrolldown_and_clear
  4109.     base    gfx
  4110.  
  4111.     tst.w    legalprint
  4112.     bne.w    .system
  4113.  
  4114.     call    OwnBlitter
  4115.     call    WaitBlit
  4116.     lea    $dff000,a5
  4117.  
  4118.     move.l    #$09f00002,bltcon0(a5)
  4119.     move.l    #-1,bltafwm(a5)
  4120.     move.l    cheightp(pc),d0
  4121.     move.l    .speed(pc),d1
  4122.     mulu.w    bwidth+2(pc),d0
  4123.     mulu.w    bwidth+2(pc),d1
  4124.     add.l    plane0(pc),d0
  4125.     subq.l    #2,d0
  4126.     move.l    d0,bltdpt(a5)
  4127.     sub.l    d1,d0
  4128.     move.l    d0,bltapt(a5)
  4129.     move.w    #0,bltamod(a5)
  4130.     move.w    #0,bltdmod(a5)
  4131.     move.l    bwidth(pc),d0
  4132.     lsr.l    #1,d0
  4133.     move.l    cheightp(pc),d1
  4134.     sub.l    .speed(pc),d1
  4135.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  4136.     bne.b    .bigblit1
  4137.     lsl.l    #6,d1
  4138.     or.l    d0,d1
  4139.     move.w    d1,bltsize(a5)
  4140.     bra.b    .blitted1
  4141. .bigblit1
  4142.     move.w    d1,bltsizv(a5)
  4143.     move.w    d0,bltsizh(a5)
  4144. .blitted1
  4145.     call    WaitBlit
  4146.     move.l    #$01000000,bltcon0(a5)
  4147.     move.l    #-1,bltafwm(a5)
  4148.     move.l    plane0(pc),bltdpt(a5)
  4149.     move.w    #0,bltdmod(a5)
  4150.  
  4151.     move.l    bwidth(pc),d0
  4152.     lsr.l    #1,d0
  4153.     move.l    .speed(pc),d1
  4154.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  4155.     bne.b    .bigblit2
  4156.     lsl.l    #6,d1
  4157.     or.l    d0,d1
  4158.     move.w    d1,bltsize(a5)
  4159.     bra.b    .blitted2
  4160. .bigblit2
  4161.     move.w    d1,bltsizv(a5)
  4162.     move.w    d0,bltsizh(a5)
  4163. .blitted2
  4164.     call    DisownBlitter
  4165.     call    WaitBlit
  4166.     rts
  4167. .system
  4168.     move.l    screenptr(pc),a3
  4169.     lea    sc_RastPort(a3),a3
  4170.     move.l    rp_BitMap(a3),a0
  4171.  
  4172.     move.l    .speed(pc),d0
  4173.     move.l    a0,a1
  4174.     suba.l    a2,a2
  4175.     move.l    barheight(pc),d1
  4176.     moveq    #0,d2
  4177.     move.l    d1,d3
  4178.     add.l    d0,d3
  4179.     move.l    cwidthp(pc),d4
  4180.     move.l    cheightp(pc),d5
  4181.     sub.l    d0,d5
  4182.     move.w    #$c0,d6
  4183.     moveq    #1,d7
  4184.     moveq    #0,d0
  4185.     call    BltBitMap
  4186.  
  4187.     move.l    a3,a1
  4188.     moveq    #0,d0
  4189.     call    SetAPen
  4190.     move.l    a3,a1
  4191.     moveq    #0,d0
  4192.     move.l    barheight(pc),d1
  4193.     move.l    cwidthp(pc),d2
  4194.     move.l    d1,d3
  4195.     add.l    .speed(pc),d3
  4196.     subq.l    #1,d3
  4197.     call    RectFill
  4198.  
  4199.     rts
  4200.  
  4201. **** text maintaining
  4202.  
  4203. textredraw:
  4204.     bsr.W    fixlinepos
  4205.     bsr.w    changescroll
  4206.     bsr.w    changenum
  4207.     bsr.w    cls
  4208.     move.l    linepos(pc),d0
  4209.     bsr.w    gotoline
  4210.     move.l    a0,d1            ;INTE d0 !! (Bara tst.l    a0)
  4211.     beq.b    .notext
  4212.     bsr.w    printpage
  4213.     bra.b    .exit
  4214. .notext                    ;Inte? Skriv ut © då!
  4215.     moveq    #0,d1
  4216.     moveq    #0,d2
  4217.     move.w    #.hailtextend-.hailtext-1,d3
  4218.     lea    .hailtext(pc),a0
  4219.     bsr.w    print
  4220. .exit
  4221.     moveq    #0,d0
  4222.     rts
  4223. ;FIXIT! Localize it!
  4224. .hailtext
  4225.  dc.b "Textread v"
  4226.  releasestr
  4227.  dc.b " - Copyright ©1992-1995 Martin Blom.",10
  4228.  dc.b "Shareware! Don't forget to send 40 SEK, 20 DM or US$ 10 to:",10,10
  4229.  dc.b "  Martin Blom",10
  4230.  dc.b "  Alsättersgatan 15A.24",10
  4231.  dc.b "S-582 51 Linköping",10
  4232.  dc.b "  Sweden",10,10
  4233.  dc.b "And yes, I prefer SEK. Send comments, bugreports and support letters to",10
  4234.  dc.b "the address above or why not email me:",10,10
  4235.  dc.b "lcs@lysator.liu.se or d93marbl@und.ida.liu.se"
  4236. .hailtextend
  4237.     even
  4238.  
  4239. fixlinepos:
  4240.     pushm    d1/a0
  4241.     move.l    lines(pc),d1
  4242.     sub.l    cheight(pc),d1
  4243.     bmi.b    .minus
  4244.     lea    linepos(pc),a0
  4245.     cmp.l    (a0),d1
  4246.     bhs.b    .ok
  4247.     move.l    d1,(a0)
  4248.     bra.b    .ok
  4249. .minus
  4250.     lea.l    linepos(pc),a0
  4251.     clr.l    (a0)
  4252. .ok
  4253.     popm    d1/a0
  4254.     rts
  4255.  
  4256. printhelp:
  4257.     base    intui
  4258.     move.l    windowptr(pc),a0
  4259.     move.l    #IDCMP_GADGETDOWN!IDCMP_GADGETUP!IDCMP_MOUSEBUTTONS!IDCMP_VANILLAKEY!IDCMP_RAWKEY,d0
  4260.     call    ModifyIDCMP
  4261.  
  4262.     move.l    windowptr(pc),a0
  4263.     or.l    #WFLG_RMBTRAP,wd_Flags(a0)
  4264.  
  4265.     bsr.w    cls
  4266.     moveq    #0,d1
  4267.     moveq    #0,d2
  4268.     move.w    #.helptextend-.helptext-1,d3
  4269.     lea    .helptext(pc),a0
  4270.     bsr.w    print
  4271.  
  4272.     move.l    windowptr(pc),a0
  4273.     move.l    wd_UserPort(a0),a2
  4274.     move.l    a2,a0
  4275.     base    exec
  4276.     call    WaitPort
  4277. .next
  4278.     move.l    a2,a0
  4279.     call    GetMsg
  4280.     tst.l    d0
  4281.     beq.b    .null
  4282.     move.l    d0,a1
  4283.     call    ReplyMsg
  4284.     bra.b    .next
  4285. .null
  4286.     base    intui
  4287.     move.l    windowptr(pc),a0
  4288.     move.l    #IDCMP_INACTIVEWINDOW!IDCMP_MOUSEBUTTONS!IDCMP_MENUVERIFY!IDCMP_MOUSEBUTTONS!ARROWIDCMP!SCROLLERIDCMP!IDCMP_REFRESHWINDOW!IDCMP_MENUPICK!IDCMP_VANILLAKEY!IDCMP_RAWKEY,d0
  4289.     call    ModifyIDCMP
  4290.  
  4291.     move.l    windowptr(pc),a0
  4292.     and.l    #~WFLG_RMBTRAP,wd_Flags(a0)
  4293.     bsr.w    textredraw
  4294.     moveq    #0,d0
  4295.     rts
  4296. ;FIXIT! Localize it!
  4297. .helptext
  4298.  dc.b 'Keys used in Textread',10
  4299.  dc.b '¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯',10
  4300.  dc.b ' Help, H, ? ....................... Show this helppage.',10
  4301.  dc.b ' Q, Shift Esc, Ctrl C ............. Quit Textread.',10
  4302.  dc.b ' Esc .............................. Close current buffer/Quit.',10
  4303.  dc.b ' Down, Return, Enter .............. Scroll text down.',10
  4304.  dc.b ' Left, Shift Up, BackSpace, PgUp .. Show previous page.',10
  4305.  dc.b ' Right, Shift Down, Space, PgDn ... Show next page.',10
  4306.  dc.b ' Alt Up/Down ...................... Move 3 pages up/down.',10
  4307.  dc.b ' Ctrl Up, T, <, Home .............. Go to first page.',10
  4308.  dc.b ' Ctrl Down, B, >, End ............. Go to last page.',10
  4309.  dc.b ' L/# / G/% ........................ Go to line/percent.',10
  4310.  dc.b ' (Shift) F1 - (Shift) F10 ......... Go to (Set) bookmark',10
  4311.  dc.b ' S, "." ........................... Search for string... (no case)',10
  4312.  dc.b ' Shift S, "/" ..................... Search for string... (case)',10
  4313.  dc.b ' N/P .............................. Find next/previous.',10
  4314.  dc.b ' W ................................ Wordwrap on/off.',10
  4315.  dc.b ' Tab .............................. Select tab size...',10
  4316.  dc.b ' Shift-E .......................... Edit text using default editor.',10
  4317.  dc.b ' 1-0 , +/-, Alt Left/Right ........ Change buffer.',10
  4318. .helptextend
  4319.     even
  4320.  
  4321. printpage:
  4322.     pushm    d0-d7/a1-a6
  4323.     tst.w    legalprint
  4324.     bne.b    .system
  4325.     bsr.b    printpage_fast
  4326.     bra.b    .exit
  4327. .system
  4328.     bsr.w    printpage_system
  4329. .exit
  4330.     popm    d0-d7/a1-a6
  4331.     rts
  4332. ;in:
  4333. * a0    text
  4334. * d0    antal rader
  4335. ;ut:
  4336. * a0    text efter sidslut
  4337. printpage_fast:
  4338.     move.l    radpos(pc),a5
  4339.     lea    font,a3
  4340.     move.l    linelen(pc),a6
  4341.     add.l    linepos(pc),a6
  4342.     move.l    bwidth(pc),d4
  4343.     move.l    d0,d5            ;antal rader
  4344.     subq.l    #1,d5
  4345.     bmi.b    .pagefinished
  4346.     moveq    #" ",d2
  4347.     moveq    #TAB,d6
  4348.     moveq    #LF,d7
  4349. .nextline
  4350.     move.l    (a5)+,a1
  4351.     moveq    #0,d1
  4352.     moveq    #0,d3
  4353.     move.b    (a6)+,d3
  4354.     cmp.w    #$ff,d3            ;255 tecken/rad inte ok, utan ev eol.
  4355.     beq.b    .linefinished
  4356. .nextchar
  4357.     moveq    #0,d0
  4358.     move.b    (a0)+,d0
  4359.     cmp.b    d2,d0            ;space
  4360.     beq.b    .space
  4361.     cmp.b    d6,d0            ;tab
  4362.     beq.b    .tab
  4363.     cmp.b    d7,d0            ;lf
  4364.     beq.b    .linefinished
  4365.     lsl.w    #3,d0
  4366.     move.l    a1,a2
  4367.     lea    (a3,d0.w),a4    ;12
  4368.     move.b    (a4)+,(a1)+    ;öka med ett för varje tecken
  4369.      add.w    d4,a2
  4370.     move.b    (a4)+,(a2)
  4371.     add.w    d4,a2
  4372.     move.b    (a4)+,(a2)
  4373.     add.w    d4,a2
  4374.     move.b    (a4)+,(a2)
  4375.     add.w    d4,a2
  4376.     move.b    (a4)+,(a2)
  4377.     add.w    d4,a2
  4378.     move.b    (a4)+,(a2)
  4379.     add.w    d4,a2
  4380.     move.b    (a4)+,(a2)
  4381.     move.b    (a4)+,(a2,d4.w)    ;2c snabbare än add d4,a2 först,6 extra
  4382.     addq.w    #1,d1
  4383. .charfinished
  4384.     dbf    d3,.nextchar
  4385. .linefinished
  4386.     dbf    d5,.nextline
  4387. .pagefinished
  4388.     rts
  4389. .space
  4390.     addq.l    #1,a1
  4391.     addq.w    #1,d1
  4392.     dbf    d3,.nextchar
  4393.     dbf    d5,.nextline
  4394.     rts
  4395. .tab
  4396.     lea    tabbar,a2
  4397.     move.b    (a2,d1.w),d0        ;word rensat
  4398.     sub.w    d1,d0
  4399.     add.w    d0,a1
  4400.     move.b    (a2,d1.w),d1
  4401.     bra.b    .charfinished
  4402.  
  4403. ;in:
  4404. * a0    text
  4405. * d0    antal rader
  4406. ;ut:
  4407. * a0    text efter sidslut
  4408. printpage_system:
  4409.     move.l    linelen(pc),a6
  4410.     add.l    linepos(pc),a6
  4411.     move.w    d0,d5
  4412.     subq.w    #1,d5
  4413.     bmi.b    .pagefinished
  4414.  
  4415.     moveq    #0,d1
  4416.     moveq    #0,d2
  4417.  
  4418. .nextline
  4419.     moveq    #0,d3
  4420.     move.b    (a6)+,d3
  4421.     cmp.w    #$ff,d3            ;255 tecken/rad inte ok, utan ev eol.
  4422.     beq.b    .linefinished
  4423.     bsr    print
  4424. .linefinished
  4425.     moveq    #0,d1
  4426.     addq.w    #1,d2
  4427.     dbf    d5,.nextline
  4428. .pagefinished
  4429.     rts
  4430.  
  4431. printline:
  4432.     pushm    d0-d7/a1-a6
  4433.     tst.w    legalprint
  4434.     bne.b    .system
  4435.     bsr.b    printline_fast
  4436.     bra.b    .exit
  4437. .system
  4438.     bsr.w    printline_system
  4439. .exit
  4440.     popm    d0-d7/a1-a6
  4441.     rts
  4442. print:
  4443.     pushm    d0-d7/a1-a6
  4444.     tst.w    legalprint
  4445.     bne.b    .system
  4446.     bsr.b    print_fast
  4447.     bra.b    .exit
  4448. .system
  4449.     bsr.b    print_system
  4450. .exit
  4451.     popm    d0-d7/a1-a6
  4452.     rts
  4453. ;in:
  4454. * d1.w    x-pos (tecken)
  4455. * d2.w    y-pos (print: tecken ; printline: pixels)
  4456. * d3.w    total längd-1 (-1 skriver nästan allt)
  4457. * a0    text
  4458. ;ut:
  4459. * a0    text uppdaterat
  4460. printline_fast:                ;INGA LF!!
  4461.     move.l    plane0(pc),a1
  4462.     mulu.w    bwidth+2(pc),d2
  4463.     add.l    d2,a1
  4464.     bra.b    printit
  4465.  
  4466. print_fast:
  4467.     move.w    d2,d4
  4468.     add.w    d4,d4
  4469.     add.w    d4,d4
  4470.     move.l    radpos(pc),a1
  4471.     move.l    (a1,d4.w),a1
  4472.  
  4473. printit:
  4474.     lea    tabbar,a5
  4475.     lea    font,a3
  4476.     move.l    bwidth(pc),d4
  4477. .nextchar
  4478.     moveq    #0,d0
  4479.     move.b    (a0)+,d0
  4480.     cmp.b    #TAB,d0
  4481.     bne.B    .notab
  4482.     move.b    (a5,d1.w),d1
  4483.     bra.b    .charfinished
  4484. .notab
  4485.     cmp.b    #LF,d0
  4486.     beq.b    .printlf
  4487.     lsl.w    #3,d0
  4488.     lea    (a1,d1.w),a2
  4489.     lea    (a3,d0.w),a4
  4490.     moveq    #8-1,d5                ;fonty?
  4491. .printchar
  4492.     move.b    (a4)+,(a2)
  4493.     add.w    d4,a2
  4494.     dbf    d5,.printchar
  4495.     addq.w    #1,d1
  4496. .charfinished
  4497.     dbf    d3,.nextchar
  4498.     rts
  4499. .printlf
  4500.     moveq    #0,d1
  4501.     addq.w    #1,d2
  4502.     dbf    d3,print_fast
  4503.     rts
  4504.  
  4505. ;in:
  4506. * d1.w    x-pos (tecken)
  4507. * d2.w    y-pos (print: tecken ; printline: pixels)
  4508. * d3.w    total längd-1 (-1 skriver nästan allt)
  4509. * a0    text
  4510. ;ut:
  4511. * a0    text uppdaterat
  4512. print_system:
  4513.     mulu.w    fonty+2(pc),d2
  4514. printline_system:            ;INGA LF!!
  4515.     mulu.w    fontx+2(pc),d1
  4516.     base    gfx
  4517.     move.l    a0,a3
  4518.     move.l    windowptr(pc),a2
  4519.     move.l    wd_RPort(a2),a2
  4520.  
  4521.     add.l    barheight(pc),d2
  4522.     add.w    rp_TxBaseline(a2),d2
  4523.  
  4524.     pushm    a0/d1
  4525.     move.l    a2,a1
  4526.     moveq    #1,d0
  4527.     call    SetAPen
  4528.     move.l    a2,a1
  4529.     moveq    #0,d0
  4530.     call    SetBPen
  4531.     popm    a0/d1
  4532. .nextline
  4533.     pushm    a0/d1
  4534.     move.l    a2,a1
  4535.     move.w    d1,d0
  4536.     move.w    d2,d1
  4537.     call    Move
  4538.     popm    a0/d1
  4539.  
  4540.     lea    temp,a1
  4541.     moveq    #0,d4
  4542.     lea    tabbar,a5
  4543. .nextchar
  4544.     moveq    #0,d0
  4545.     move.b    (a0)+,d0
  4546.     cmp.b    #TAB,d0
  4547.     bne.b    .notab
  4548.  
  4549.     move.b    (a5,d1.w),d0
  4550.     sub.b    d1,d0
  4551.     add.b    d0,d1
  4552.     add.b    d0,d4
  4553.     subq.b    #1,d0
  4554. .filltab
  4555.     move.b    #" ",(a1)+
  4556.     dbf    d0,.filltab
  4557.     bra.b    .charfinished
  4558. .notab
  4559.     cmp.b    #LF,d0
  4560.     beq.b    .printlf
  4561.     move.b    d0,(a1)+
  4562.     addq.w    #1,d4
  4563.     addq.w    #1,d1
  4564. .charfinished
  4565.     dbf    d3,.nextchar
  4566.     pushm    a0/d1
  4567.     lea    temp,a0
  4568.     move.l    a2,a1
  4569.     move.w    d4,d0
  4570.     call    Text
  4571.     popm    a0/d1
  4572.     rts
  4573. .printlf
  4574.     pushm    a0/d1
  4575.     lea    temp,a0
  4576.     move.l    a2,a1
  4577.     move.w    d4,d0
  4578.     call    Text
  4579.     popm    a0/d1
  4580.  
  4581.     moveq    #0,d1
  4582.     add.w    fonty+2(pc),d2
  4583.     dbf    d3,.nextline
  4584.     rts
  4585.  
  4586. ;in:
  4587. * d0    FALSE om Open, TRUE om Save
  4588. ;ut:
  4589. * d0    pek till filnamn med sökväg, eller NULL om fel/cancel
  4590. askfile:
  4591.     lea    filereqsave(pc),a0
  4592.     clr.l    (a0)
  4593.     lea    filereqtitle(pc),a1
  4594.     lea    openfiletext(pc),a2
  4595.     tst.l    d0
  4596.     beq.b    .wasopen
  4597.     addq.l    #TRUE,(a0)
  4598.     lea    savefiletext(pc),a2
  4599. .wasopen
  4600.     move.l    a2,(a1)
  4601.  
  4602.     base    asl
  4603.     move.l    filereqptr(pc),a0
  4604.     lea    filereqtags(pc),a1
  4605.     call    AslRequest
  4606.     tst.l    d0
  4607.     beq.s    .error
  4608.  
  4609.     move.l    filereqptr(pc),a0
  4610.     move.l    fr_Drawer(a0),a1
  4611.     move.l    fr_Pattern(a0),a0
  4612.     lea    filereqdir(pc),a2
  4613.     lea    filereqpat(pc),a3
  4614.     move.w    #255,d0
  4615. .copydir
  4616.     move.b    (a1)+,(a2)+
  4617.     dbeq    d0,.copydir
  4618.     moveq    #63,d0
  4619. .copypat
  4620.     move.b    (a0)+,(a3)+
  4621.     dbeq    d0,.copypat
  4622.  
  4623.     move.l    filereqptr(pc),a0
  4624.     move.l    fr_File(a0),a1
  4625.     move.l    fr_Drawer(a0),a0
  4626.  
  4627.     lea    temp,a2
  4628.     move.w    #tempsize,d0
  4629.     bsr.w    pathnfiletobuff
  4630.     tst.l    d0
  4631.     bmi.b    .error
  4632. .exit
  4633.     move.l    #temp,d0
  4634.     rts
  4635. .error
  4636.     moveq    #0,d0
  4637.     rts
  4638.  
  4639. ;in:
  4640. * d0    pek till filnamn med sökväg
  4641. ;ut:
  4642. * d0    NULL om ok
  4643. openfile:
  4644.     pushm    d1-d7/a0-a6
  4645.     move.l    d0,-(sp)
  4646.  
  4647.     Message    loadingtext
  4648.  
  4649.     move.l    (sp),a0
  4650.     bsr.w    loadfile
  4651.     move.l    d0,d4            ;->
  4652.     move.l    a0,a2
  4653.     move.l    d1,d3
  4654.  
  4655.     base    exec
  4656.     move.l    fileaddr(pc),a1
  4657.     move.l    filememlen(pc),d0
  4658.     beq.B    .nofileinmem
  4659.     call    FreeMem
  4660. .nofileinmem
  4661.     lea    fileaddr(pc),a0
  4662.     move.l    a2,(a0)
  4663.  
  4664.     lea    filememlen(pc),a0
  4665.     move.l    d3,(a0)
  4666.  
  4667.     lea    filelen(pc),a0
  4668.     move.l    d2,(a0)
  4669.     clr.l    linepos
  4670.     lea    fkeys_lines(pc),a0
  4671.     moveq    #9,d0
  4672. .clrpos
  4673.     move.l    #-1,(a0)+
  4674.     dbf    d0,.clrpos
  4675.  
  4676.     move.l    (sp)+,d2
  4677.     move.l    d2,d1
  4678.  
  4679.     base    dos
  4680.     call    FilePart
  4681.     move.l    d0,a0
  4682.     lea    filename(pc),a1
  4683.     moveq    #31,d0
  4684. .copynameloop
  4685.     move.b    (a0)+,(a1)+
  4686.     dbeq    d0,.copynameloop
  4687.  
  4688.     move.l    d2,d1
  4689.     call    PathPart
  4690.     move.l    d0,a0
  4691.     clr.b    (a0)        ;klipp bort filnamnet
  4692.     move.l    d2,a0
  4693.     lea    filereqdir(pc),a1
  4694.     move.w    #255,d0
  4695. .copydirloop
  4696.     move.b    (a0)+,(a1)+
  4697.     dbeq    d0,.copydirloop
  4698.  
  4699.     Message    screentitle
  4700.  
  4701.     tst.l    d4            ;<-
  4702.     bne.b    .exit
  4703.  
  4704.     tst.w    alwaysremansi
  4705.     beq.b    .dontremansi
  4706.     bsr.w    RemoveANSI
  4707. .dontremansi
  4708.     tst.w    alwaysremcr
  4709.     beq.b    .dontremcr
  4710.     bsr.w    RemoveCR
  4711. .dontremcr
  4712.     bsr.w    countlines
  4713.     tst.l    d0
  4714.     bne.b    .error
  4715.     bsr.w    textredraw
  4716.  
  4717. .exit
  4718.     moveq    #0,d0
  4719. .error
  4720.     popm    d1-d7/a0-a6
  4721.     rts
  4722.  
  4723. ;in:
  4724. * a0    filename
  4725. ;ut:
  4726. * d0    0 om ok, -1 om fel
  4727. * d1    filememlen    (allokerat minne)
  4728. * d2    filelen        (filstorlek)
  4729. * a0    fileaddr
  4730. loadfile:
  4731.     clr.l    .addr
  4732.     clr.l    .memlen
  4733.     clr.l    .len
  4734.  
  4735.     base    xpk
  4736.     move.l    a6,d0
  4737.     beq.b    .pp            ;ingen xpk, anv pp
  4738.  
  4739.     move.l    a0,.xpkfilename
  4740.     lea    .xpktags(pc),a0
  4741.     call    XpkUnpack
  4742.     tst.l    d0
  4743.     bne.w    .error
  4744.     bra.w    .fileloadedok
  4745. .pp
  4746.     base    pp            ;a0 klar
  4747.     move.l    a6,d0
  4748.     beq.b    .dos            ;ingen pp, anv dos
  4749.     lea    .addr(pc),a1
  4750.     lea    .len(pc),a2
  4751.     suba.l    a3,a3
  4752.     moveq    #DECR_POINTER,d0
  4753.     moveq    #MEMF_PUBLIC,d1
  4754.     call    ppLoadData
  4755.     tst.l    d0
  4756.     bne.W    .error
  4757.     bra.w    .fileloadedok
  4758. .dos
  4759.     base    dos
  4760.     move.l    a0,d1
  4761.     move.l    #MODE_OLDFILE,d2
  4762.     call    Open
  4763.     move.l    d0,.file
  4764.     bne.s    .dosnoerr1
  4765.     bsr.w    .dosclean
  4766.     lea    errnofile(pc),a1
  4767.     bra.w    .error
  4768. .dosnoerr1
  4769.     moveq    #DOS_FILEHANDLE,d1
  4770.     lea    tag_done(pc),a0
  4771.     move.l    a0,d2
  4772.     call    AllocDosObject
  4773.     move.l    d0,.finfo
  4774.     bne.s    .dosnoerr2
  4775.     bsr.w    .dosclean
  4776.     lea    errnomem(pc),a1
  4777.     bra.w    .error
  4778. .dosnoerr2
  4779.     move.l    .file(pc),d1
  4780.     move.l    .finfo(pc),d2
  4781.     call    ExamineFH
  4782.     tst.l    d0
  4783.     bne.s    .dosnoerr3
  4784.     bsr.s    .dosclean
  4785.     lea    errnofile(pc),a1
  4786.     bra.w    .error
  4787. .dosnoerr3
  4788.     move.l    .finfo(pc),a0
  4789.     move.l    fib_Size(a0),d0
  4790.     lea    .len(pc),a0
  4791.     move.l    d0,(a0)
  4792.     moveq    #MEMF_ANY,d1
  4793.     base    exec
  4794.     call    AllocMem
  4795.     lea    .addr(pc),a0
  4796.     move.l    d0,(a0)
  4797.     bne.s    .dosnoerr4
  4798.     bsr.s    .dosclean
  4799.     lea    errnomem(pc),a1
  4800.     bra.w    .error
  4801. .dosnoerr4
  4802.     base    dos
  4803.     move.l    .file(pc),d1
  4804.     move.l    .addr(pc),d2
  4805.     move.l    .len(pc),d3
  4806.     call    Read
  4807.     cmp.l    d0,d3
  4808.     beq.s    .dosnoerr5
  4809.     bsr.s    .dosclean
  4810.     base    exec
  4811.     move.l    .addr(pc),a1
  4812.     move.l    .len(pc),d0
  4813.     beq.B    .dosnofilemem
  4814.     call    FreeMem
  4815. .dosnofilemem
  4816.     lea    errnofile(pc),a1
  4817.     bra.w    .error
  4818. .dosnoerr5
  4819.     bsr.s    .dosclean
  4820.     bra.s    .fileloadedok
  4821. .dosclean
  4822.     base    dos
  4823.     move.l    .file(pc),d1
  4824.     beq.s    .doserr_nofile
  4825.     clr.l    .file
  4826.     call    Close
  4827. .doserr_nofile
  4828.     move.l    .finfo(pc),d2
  4829.     beq.s    .doserr_nofinfo
  4830.     clr.l    .finfo
  4831.     moveq    #DOS_FILEHANDLE,d1
  4832.     call    FreeDosObject
  4833.     clr.l    .finfo
  4834. .doserr_nofinfo
  4835.     rts
  4836. .fileloadedok
  4837.     move.l    .addr(pc),a0
  4838.     move.l    .memlen(pc),d1
  4839.     bne.b    .memlenok
  4840.     move.l    .len(pc),d1        ;pp & dos har bara 2 tal, xpk har 3
  4841. .memlenok
  4842.     move.l    .len(pc),d2
  4843.  
  4844.     moveq    #0,d0
  4845.     rts
  4846.  
  4847. .addr    dc.l    0
  4848. .len    dc.l    0
  4849. .memlen    dc.l    0
  4850. .file    dc.l    0    ;dosloader
  4851. .finfo    dc.l    0    ;dosloader
  4852.  
  4853. .xpktags
  4854.     dc.l    XPK_InName
  4855. .xpkfilename
  4856.     dc.l    0
  4857.     dc.l    XPK_GetError,XPKerrbuf
  4858.     dc.l    XPK_GetOutBuf,.addr
  4859.     dc.l    XPK_GetOutLen,.len
  4860.     dc.l    XPK_GetOutBufLen,.memlen
  4861.     dc.l    XPK_PassThru,-1
  4862.     dc.l    TAG_DONE
  4863.     even
  4864. ;in:
  4865. * .errbuf Textsträng med felmeddelande
  4866. * eller
  4867. * d0    pp error code
  4868. * eller
  4869. * a1    felmeddelande (dos)
  4870. .error
  4871.     base    xpk
  4872.     move.l    a6,d1
  4873.     beq.b    .pperr
  4874.     lea    XPKerrbuf,a1
  4875.     bra.b    .showerr
  4876. .pperr
  4877.     base    pp
  4878.     move.l    a6,d1
  4879.     beq.b    .doserr
  4880.     call    ppErrorMessage
  4881.     move.l    d0,a1
  4882.     bra.w    .showerr
  4883. .doserr
  4884. .showerr
  4885.     lea    oktext(pc),a2
  4886.     suba.l    a4,a4
  4887.     bsr.w    requester
  4888.  
  4889.     base    exec
  4890.     move.l    .addr(pc),a1
  4891.     move.l    .len(pc),d0
  4892.     beq.B    .noerrorfileinmem
  4893.     call    FreeMem
  4894. .noerrorfileinmem
  4895.     moveq    #-1,d0
  4896.     moveq    #0,d1
  4897.     move    #0,d2
  4898.     suba.l    a0,a0
  4899.     rts
  4900.  
  4901. ;in:
  4902. * d0    pek till filnamn
  4903. ;ut:
  4904. * d0    NULL om ok
  4905. savefile:
  4906.     pushm    d0
  4907.     Message    savingtext
  4908.     base    dos
  4909.     popm    d5                    ;-=>
  4910.     move.l    d5,d1
  4911.     move.l    #MODE_NEWFILE,d2
  4912.     call    Open
  4913.     move.l    d0,d7                    ;->
  4914.     beq.w    .exit
  4915.     move.l    d7,d1                    ;<-
  4916.     move.l    fileaddr(pc),d2
  4917.     move.l    filelen(pc),d3
  4918.     call    Write
  4919.     moveq    #0,d6                    ;=>
  4920.     cmp.l    d0,d3
  4921.     beq.b    .writeok
  4922.  
  4923.     lea    writeerr(pc),a1
  4924.     lea    oktext(pc),a2
  4925.     suba.l    a4,a4
  4926.     bsr    requester
  4927.  
  4928.     moveq    #1,d6                    ;=>
  4929. .writeok
  4930.     base    dos
  4931.     move.l    d7,d1                    ;<-
  4932.     call    Close
  4933.  
  4934.     move.l    d5,d1                    ;<=-
  4935.     base    dos
  4936.     call    FilePart
  4937.     move.l    d0,a0
  4938.     lea    filename(pc),a1
  4939.     moveq    #31,d0
  4940. .copynameloop
  4941.     move.b    (a0)+,(a1)+
  4942.     dbeq    d0,.copynameloop
  4943.  
  4944.     move.l    d5,d1
  4945.     call    PathPart
  4946.     move.l    d0,a0
  4947.     clr.b    (a0)        ;klipp bort filnamnet
  4948.     move.l    d5,a0
  4949.     lea    filereqdir(pc),a1            ;<=-
  4950.     move.w    #255,d0
  4951. .copydirloop
  4952.     move.b    (a0)+,(a1)+
  4953.     dbeq    d0,.copydirloop
  4954.  
  4955. .exit
  4956.     Message    screentitle
  4957.     move.l    d6,d0                    ;<=
  4958.     rts
  4959.  
  4960.  
  4961. ;calls countlines if neccessary (sp?)
  4962. recountlines:
  4963.     move.l    clcwidth(pc),d0
  4964.     cmp.l    cwidth(pc),d0
  4965.     bne.b    countlines
  4966.     rts
  4967.  
  4968. ;ut:
  4969. * d0    0 om ok, eller felkod
  4970. * linelen: pek till minnesblock med radlängder
  4971. * linelensize: minnesblockets storlek
  4972. countlines:
  4973.     Message    counting
  4974.  
  4975. ;    Onödigt. Bättre att man får en rad med längd 255=eol markering.
  4976. ;    lea    filelen(pc),a0
  4977. ;    tst.l    (a0)
  4978. ;    beq.w    .exit
  4979.  
  4980.     base    exec        ;fria gammalt minne
  4981.     move.l    linelen(pc),a1
  4982.     move.l    linelensize(pc),d0
  4983.     beq.b    .ingetlineminne
  4984.     call    FreeMem
  4985. .ingetlineminne
  4986.     lea    linelen(pc),a0
  4987.     lea    notnull(pc),a1            ;pek till 255
  4988.     move.l    a1,(a0)
  4989.     lea    linelensize(pc),a0
  4990.     clr.l    (a0)
  4991.  
  4992. ;    moveq    #LF,d1
  4993. ;    moveq    #0,d0
  4994. ;    move.l    fileaddr(pc),a0
  4995. ;    move.l    filelen(pc),d0
  4996. ;    beq.s    .nofile
  4997. ;.cntlf
  4998. ;    subq.l    #1,d0
  4999. ;    beq.s    .done
  5000. ;    cmp.b    (a0)+,d1
  5001. ;    bne.s    .cntlf
  5002. ;    addq.l    #1,d2
  5003. ;    bra.s    .cntlf
  5004. .done
  5005. .nofile
  5006.  
  5007.     move.l    #1024,d2        ;1024 rader till att börja med
  5008. ;    move.l    filelen(pc),d2
  5009. ;    move.l    cwidth(pc),d0
  5010. ;    divu    d0,d2
  5011. ;    bvc.s    .under64k
  5012. ;    move.w    #$ffff,d2
  5013. ;.under64k
  5014.  
  5015.     cmp.w    #512,d2
  5016.     bhs.s    .sizeok
  5017.     move.w    #512,d2
  5018. .sizeok
  5019.     and.l    #$ffff,d2        ;bort med resten!
  5020.     bsr.w    alloclinemem
  5021.     tst.l    d0
  5022.     beq.w    .error_nomem
  5023.  
  5024.     move.l    fileaddr(pc),a0
  5025.     move.l    a0,a1
  5026.     add.l    filelen(pc),a1
  5027.  
  5028.     lea    tabbar,a2
  5029.     move.l    linelen(pc),a4
  5030.     move.l    linelensize(pc),a5
  5031.     add.l    a4,a5
  5032.     move.l    cwidth(pc),d1
  5033.     subq.l    #1,d1
  5034.     moveq    #1,d2        ;alltid 1 rad!
  5035.     moveq    #LF,d3
  5036.     moveq    #TAB,d4
  5037.     moveq    #" ",d5
  5038.     tst.w    wordwrap
  5039.     bne.B    .ww
  5040. .nextline
  5041.     moveq    #0,d0
  5042.     moveq    #-1,d7
  5043. .huntlf
  5044.     cmp.l    a0,a1        ;sista tecknet
  5045.     beq.b    .klar
  5046.     move.b    (a0)+,d6
  5047.     addq.l    #1,d7
  5048.     cmp.b    d4,d6        ;TAB?
  5049.     bne.B    .notab
  5050.     move.b    (a2,d0.w),d0
  5051.     bra.b    .testok
  5052. .notab
  5053.     addq.l    #1,d0        ;nej,add 1
  5054.     cmp.b    d3,d6        ;LF?
  5055.     beq.B    .lineok
  5056. .testok
  5057.     cmp.l    d1,d0        ;nej fortsätt om ok
  5058.     bls.b    .huntlf
  5059.  
  5060.     move.b    (a0),d6
  5061.     cmp.b    d3,d6        ;LF
  5062.     beq.b    .add1
  5063.     cmp.b    d4,d6        ;TAB?
  5064.     beq.b    .add1
  5065.     cmp.b    d5,d6        ;space
  5066.     bne.b    .lineok
  5067. .add1
  5068.     addq.l    #1,a0
  5069.     addq.l    #1,d7
  5070. .lineok
  5071.     addq.l    #1,d2        ;ja, ny rad
  5072.     move.b    d7,(a4)+
  5073.     cmp.l    a4,a5
  5074.     bne.b    .nextline
  5075.     move.l    d2,-(sp)
  5076.     move.l    linelensize(pc),d2
  5077.     add.l    #1024,d2        ;öka med 1024 i taget
  5078.     bsr.w    alloclinemem
  5079.     move.l    (sp)+,d2
  5080.     tst.l    d0
  5081.     beq.w    .error_nomem
  5082.     move.l    d0,a4
  5083.     move.l    linelen(pc),a5
  5084.     add.l    linelensize(pc),a5
  5085.     bra.b    .nextline
  5086. .klar
  5087.     move.b    d7,(a4)+        ;sista radlängden...
  5088.     lea    lines(pc),a0
  5089.     move.l    d2,(a0)
  5090.     bra.b    .exit
  5091. .ww
  5092. ..nextline
  5093.     moveq    #0,d0
  5094.     suba.l    a3,a3
  5095.     moveq    #-1,d7
  5096.     suba.l    a6,a6
  5097. ..huntlf
  5098.     cmp.l    a0,a1        ;sista tecknet
  5099.     beq.b    .klar
  5100.  
  5101.     move.b    (a0)+,d6
  5102.     addq.l    #1,d7
  5103.     cmp.b    d4,d6        ;TAB?
  5104.     bne.b    ..notab
  5105.     move.l    a0,a3        ;spara tab
  5106.     move.l    d7,a6
  5107.     move.b    (a2,d0.w),d0
  5108.     bra.b    ..testok
  5109. ..notab
  5110.     cmp.b    d5,d6
  5111.     bne.b    ..nospace
  5112.     move.l    a0,a3        ;spara space
  5113.     move.l    d7,a6
  5114. ..nospace
  5115.     addq.l    #1,d0        ;nej,add 1
  5116.     cmp.b    d3,d6        ;LF?
  5117.     beq.B    ..lineok
  5118. ..testok
  5119.     cmp.w    d1,d0        ;nej fortsätt om ok
  5120.     bls.b    ..huntlf
  5121.  
  5122.     move.b    (a0),d6
  5123.     cmp.b    d3,d6        ;LF
  5124.     beq.b    ..add1
  5125.     cmp.b    d4,d6        ;TAB?
  5126.     beq.b    ..add1
  5127.     cmp.b    d5,d6        ;space
  5128.     beq.b    ..add1
  5129.     move.w    a6,d6        ;antingen är första tecknet " " eller TAB eller
  5130.     beq.b    ..lineok    ;bara ett ord.
  5131.     move.l    a3,a0
  5132.     move.l    a6,d7
  5133.     bra.b    ..lineok
  5134. ..add1
  5135.     addq.l    #1,a0
  5136.     addq.l    #1,d7
  5137. ..lineok
  5138.     addq.l    #1,d2        ;ja, ny rad
  5139.     move.b    d7,(a4)+
  5140.     cmp.l    a4,a5
  5141.     bne.b    ..nextline
  5142.     move.l    d2,-(sp)
  5143.     move.l    linelensize(pc),d2
  5144.     add.l    #1024,d2    ;öka med 1024 i taget
  5145.     bsr.w    alloclinemem
  5146.     move.l    (sp)+,d2
  5147.     tst.l    d0
  5148.     beq.b    .error_nomem
  5149.     move.l    d0,a4
  5150.     move.l    linelen(pc),a5
  5151.     add.l    linelensize(pc),a5
  5152.     bra.b    ..nextline
  5153.  
  5154. .exit
  5155.     moveq    #0,d0            ;Eftersom radlängden kanske ändrats,
  5156.     bsr.w    gotoline        ;är det bäst att se till att vi inte
  5157.                     ;är nånstant i mitten på en rad.
  5158.     bsr    updatemenu
  5159.     lea    clcwidth(pc),a0
  5160.     move.l    cwidth(pc),(a0)
  5161.     moveq    #0,d0
  5162.     rts
  5163. .error_nomem
  5164.     bsr.b    .exit
  5165.     lea    clcwidth(pc),a0
  5166.     clr.l    (a0)
  5167.     moveq    #err_nomem,d0
  5168.     rts
  5169.  
  5170. alloclinemem:    ;d2 size
  5171.     movem.l    d1-a6,-(sp)
  5172.     base    exec
  5173.     move.l    d2,d0
  5174.     move.l    #MEMF_PUBLIC!MEMF_CLEAR,d1
  5175.     call    AllocMem
  5176.     move.l    d0,d3            ;->
  5177.     move.l    d0,a2            ;->
  5178.     beq.B    .error
  5179.     move.l    linelensize(pc),d0
  5180.     beq.b    .ingetminne
  5181.     move.l    d0,d1
  5182.     subq.l    #1,d1
  5183.     move.l    linelen(pc),a0
  5184.     move.l    d3,a1            ;<-
  5185. .loop
  5186.     move.b    (a0)+,(a1)+
  5187.     dbf    d1,.loop
  5188.     move.l    a1,a2            ;->
  5189.     move.l    linelen(pc),a1        ;d0 ok
  5190.     call    FreeMem
  5191. .ingetminne
  5192.     lea    linelen(pc),a0
  5193.     move.l    d3,(a0)            ;<-
  5194.     lea    linelensize(pc),a0
  5195.     move.l    d2,(a0)
  5196.     move.l    a2,d0    ;addr att fortsätta    ;<-
  5197. .exit
  5198.     movem.l    (sp)+,d1-a6
  5199.     rts
  5200. .error
  5201.     moveq    #0,d0
  5202.     bra.b    .exit
  5203.  
  5204. **** menus
  5205.  
  5206. ;in:
  5207. * a0    pek till menystrukt
  5208. * a1    pek till statusword
  5209. * d1    förstörs       ¯¯¯¯
  5210. ;ut:
  5211. * d0    0 om ingen förändring, annars 1
  5212. checkmark:
  5213.     moveq    #0,d1
  5214.     move.w    mi_Flags(a0),d0
  5215.     and.w    #CHECKED,d0
  5216.     beq.b    .notchecked
  5217.     moveq    #1,d1
  5218. .notchecked
  5219.     moveq    #0,d0
  5220.     cmp.w    (a1),d1
  5221.     beq.b    .exit
  5222.     moveq    #1,d0
  5223. .exit
  5224.     move.w    d1,(a1)
  5225.     movem.l    d0-a6,-(sp)
  5226.     bsr.w    changenum        ;uppdatera statusbokstäverna därnere!
  5227.     movem.l    (sp)+,d0-a6
  5228.     rts
  5229.  
  5230. updatemenu:
  5231. ;update thisbuffnum
  5232.     move.l    thisbuff(pc),a1
  5233.     lea    bufflist(pc),a0
  5234.     lea    bnum(pc),a2
  5235.     clr.l    (a2)
  5236.     lea    bmax(pc),a3
  5237.     clr.l    (a3)
  5238. .stepdown
  5239.     TSTNODE    a0,a0
  5240.     beq.b    .fel
  5241.     addq.l    #1,(a2)
  5242.     addq.l    #1,(a3)
  5243.     cmp.l    a0,a1
  5244.     bne.b    .stepdown
  5245. .stepdown2
  5246.     TSTNODE    a0,a0
  5247.     beq.b    .klar
  5248.     addq.l    #1,(a3)
  5249.     bra.b    .stepdown2
  5250. .klar
  5251. .fel
  5252.     base    intui
  5253.     lea    bufflist(pc),a0
  5254.     move.l    MLH_HEAD(a0),d0
  5255.     cmp.l    MLH_TAILPRED(a0),d0
  5256.     bne.b    .notlast
  5257.     move.l    windowptr(pc),a0
  5258.     move.w    #$1f<<11!10<<5!0,d0    ;reveal... item
  5259.     call    OffMenu
  5260. ;    move.l    windowptr(pc),a0
  5261. ;    move.w    #$1f<<11!11<<5!0,d0    ;close item
  5262. ;    call    OffMenu
  5263.     bra.b    .closeok
  5264. .notlast
  5265.     move.l    windowptr(pc),a0
  5266.     move.w    #$1f<<11!10<<5!0,d0    ;reveal... item
  5267.     call    OnMenu
  5268. ;    move.l    windowptr(pc),a0
  5269. ;    move.w    #$1f<<11!11<<5!0,d0    ;close item
  5270. ;    call    OnMenu
  5271. .closeok
  5272.     lea.l    legalprint(pc),a0
  5273.     tst.w    (a0)
  5274.     bne.b    .legal
  5275.     move.l    windowptr(pc),a0
  5276.     move.w    #$1f<<11!4<<5!1,d0    ;nofake item
  5277.     call    OnMenu
  5278.     bra.b    .legalchecked
  5279. .legal
  5280.     move.l    windowptr(pc),a0
  5281.     move.w    #$1f<<11!4<<5!1,d0    ;nofake item
  5282.     call    OffMenu
  5283. .legalchecked
  5284.     lea.l    foreignbitmap(pc),a0
  5285.     tst.w    (a0)
  5286.     bne.b    .foreign
  5287.     move.l    windowptr(pc),a0
  5288.     move.w    #$1f<<11!5<<5!1,d0    ;legalprint item
  5289.     call    OnMenu
  5290.     bra.b    .foreignchecked
  5291. .foreign
  5292.     move.l    windowptr(pc),a0
  5293.     move.w    #$1f<<11!5<<5!1,d0    ;nofake item
  5294.     call    OffMenu
  5295. .foreignchecked
  5296.  
  5297.     move.l    diskfontbase(pc),d0
  5298.     bne.b    .diskfontchecked
  5299.     move.l    windowptr(pc),a0
  5300.     move.w    #$1f<<11!10<<5!1,d0    ;nofake item
  5301.     call    OffMenu
  5302. .diskfontchecked
  5303.  
  5304.     lea.l    filelen(pc),a0
  5305.     tst.l    (a0)
  5306.     beq.b    .notextinmem
  5307.     move.l    windowptr(pc),a0
  5308.     move.w    #$1f<<11!$3f<<5!2,d0    ;commands menu
  5309.     call    OnMenu
  5310.     move.l    windowptr(pc),a0
  5311.     move.w    #$1f<<11!7<<5!0,d0    ;print item
  5312.     call    OnMenu
  5313.     pea    menutext(pc)
  5314.     bra.b    .fixmenu
  5315. .notextinmem
  5316.     move.l    windowptr(pc),a0
  5317.     move.w    #$1f<<11!$3f<<5!2,d0    ;commands menu
  5318.     call    OffMenu
  5319.     move.l    windowptr(pc),a0
  5320.     move.w    #$1f<<11!7<<5!0,d0    ;print item
  5321.     call    OffMenu
  5322.     pea    menuemptytext(pc)
  5323. .fixmenu
  5324.     base    exec
  5325.     lea    screentitle,a3
  5326.     move.l    (sp)+,a0
  5327.     lea    .args(pc),a1
  5328.     move.l    lines(pc),16(a1)
  5329.     lea    .rawdofmtfunc(pc),a2
  5330.     call    RawDoFmt
  5331.  
  5332.     Message    screentitle
  5333.     rts
  5334.  
  5335. .rawdofmtfunc
  5336.     move.b    d0,(a3)+
  5337.     rts
  5338.  
  5339. .releasestr
  5340.     releasestr
  5341.     dc.b    0
  5342.     even
  5343.  
  5344. .args
  5345.     dc.l    .releasestr
  5346. bnum:    dc.l    0    ;buffer #
  5347. bmax:    dc.l    0
  5348.     dc.l    filename
  5349.     dc.l    0    ;lines
  5350.  
  5351. updatecheckmarks:
  5352.     base    intui
  5353.     move.l    windowptr(pc),a0
  5354.     call    ClearMenuStrip
  5355.  
  5356.     move.l    winmenuptr(pc),a0
  5357. .nextmenu
  5358.     move.l    a0,d1    ;tst!
  5359.     beq.b    .exit
  5360.     move.l    mu_FirstItem(a0),a1
  5361. .nextitem
  5362.     move.l    a1,d1    ;tst!
  5363.     beq.B    .noitem
  5364.     move.l    mi_SubItem(a1),a2
  5365. .nextsub
  5366.     move.l    a2,d1    ;tst!
  5367.     beq.B    .nosub
  5368.  
  5369.     GTMENUITEM_USERDATA    a2,a3
  5370.     move.w    mi_Flags(a2),d1
  5371.     move.w    d1,d3
  5372.     and.w    #CHECKIT,d1
  5373.     beq.b    .nosubflag
  5374.     or.w    #CHECKED,d3    ;sätt
  5375.     tst.w    -(a3)        ;wordet före är status
  5376.     bne.B    .subok        ;om satt
  5377.     and.w    #~CHECKED,d3    ;rensa
  5378. .subok
  5379.     move.w    d3,mi_Flags(a2)
  5380. .nosubflag
  5381.     move.l    mi_NextItem(a2),a2
  5382.     bra.b    .nextsub
  5383. .nosub
  5384.     GTMENUITEM_USERDATA    a1,a3
  5385.     move.w    mi_Flags(a1),d1
  5386.     move.w    d1,d3
  5387.     and.w    #CHECKIT,d1
  5388.     beq.b    .noitemflag
  5389.     or.w    #CHECKED,d3    ;sätt
  5390.     tst.w    -(a3)        ;wordet före är status
  5391.     bne.B    .itemok        ;om satt
  5392.     and.w    #~CHECKED,d3    ;rensa
  5393. .itemok
  5394.     move.w    d3,mi_Flags(a1)
  5395. .noitemflag
  5396.     move.l    mi_NextItem(a1),a1
  5397.     bra.b    .nextitem
  5398. .noitem
  5399.     move.l    mu_NextMenu(a0),a0
  5400.     bra.b    .nextmenu
  5401. .exit
  5402.     move.l    windowptr(pc),a0
  5403.     move.l    winmenuptr(pc),a1
  5404.     call    ResetMenuStrip
  5405.     bsr.w    changenum    ;uppdatera IWSC därnere!
  5406.     moveq    #0,d0
  5407.     rts
  5408.  
  5409. **** find
  5410.  
  5411. search_case:    dc.w    0    ;1=case sensitive
  5412. search_wild:    dc.w    0    ;1=wildcards on
  5413. search_dir:    dc.w    0    ;1=backwards
  5414. search_then:    dc.w    0    ;1=restart
  5415.  
  5416. searchlen:    dc.w    0
  5417.  
  5418. search:
  5419.     tst.l    filelen
  5420.     beq.s    .exit
  5421.     jsr    requestsearch
  5422.     cmp.w    #1,d0
  5423.     bne.s    .exit
  5424.  
  5425.     moveq    #-1,d0
  5426.     lea    searchstring,a0
  5427. .calclen
  5428.     addq.w    #1,d0
  5429.     tst.b    (a0)+
  5430.     bne.b    .calclen
  5431.     lea    searchlen(pc),a0
  5432.     move.w    d0,(a0)
  5433.     tst.w    search_dir
  5434.     bne.w    searchprev
  5435.     bra.w    searchnext
  5436. .exit
  5437.     moveq    #0,d0
  5438.     rts
  5439.  
  5440. ;in:
  5441. * a0    addr to first char found
  5442. * a2    addr to last char found +1 (if a0=a2, mark the whole line)
  5443. searchfound:
  5444.     move.l    a2,a1
  5445.     pushm    a0
  5446.     bsr    searchmarkfound
  5447.     popm    a0
  5448.     bsr.w    getline
  5449.     subq.l    #1,d0
  5450.     lea    linepos(pc),a0
  5451.     move.l    d0,(a0)
  5452.     bsr.w    textredraw
  5453.  
  5454.     bsr    setwritemask
  5455.  
  5456.     move.l    a2,a1
  5457.     moveq    #RP_COMPLEMENT,d0
  5458.     call    SetDrMd
  5459.  
  5460.     move.l    foundlinestart(pc),d1
  5461.     sub.l    linepos(pc),d1
  5462.     bmi.b    .quit
  5463.     cmp.l    cheight(pc),d1
  5464.     bhs.b    .quit
  5465.     mulu.w    fonty+2(pc),d1
  5466.     add.l    barheight(pc),d1
  5467.     move.w    d1,d3
  5468.     add.w    fonty+2(pc),d3
  5469.     subq.w    #1,d3
  5470.     move.w    foundcolstart(pc),d0
  5471.     mulu.w    fontx+2(pc),d0
  5472.     move.w    foundcolend(pc),d2
  5473.     mulu.w    fontx+2(pc),d2
  5474.     beq.b    .quit
  5475.     subq.l    #1,d2
  5476.     move.l    a2,a1
  5477.     call    RectFill
  5478. .quit
  5479.     move.l    a2,a1
  5480.     moveq    #1,d0
  5481.     call    SetAPen
  5482.     move.l    a2,a1
  5483.     moveq    #0,d0
  5484.     call    SetBPen
  5485.     move.l    a2,a1
  5486.     moveq    #RP_JAM2,d0
  5487.     call    SetDrMd
  5488.     moveq    #0,d0
  5489.     rts
  5490.  
  5491. searchnotfound:
  5492.     base    intui
  5493.     move.l    screenptr(pc),a0
  5494.     call    DisplayBeep
  5495.     bra.w    textredraw
  5496. searchnext:
  5497.     tst.l    filelen
  5498.     beq.s    .exit
  5499.     tst.b    searchstring
  5500.     beq.s    searchnotfound
  5501.     Message    searching
  5502.     tst.w    search_wild
  5503.     beq.s    .nowild
  5504.     bsr    searchwildnext
  5505.     bra.s    .exit
  5506. .nowild
  5507.     bsr    searchnowildnext
  5508. .exit
  5509.     Message    screentitle
  5510.     moveq    #0,d0
  5511.     rts
  5512. searchnowildnext:
  5513.     move.l    linepos(pc),d0
  5514.     addq.l    #1,d0
  5515.     bsr.w    gotoline
  5516.     tst.w    search_case
  5517.     beq.W    .case
  5518.     move.l    fileaddr(pc),d0
  5519.     add.l    filelen(pc),d0
  5520.     sub.l    a0,d0
  5521.     beq.w    searchnotfound
  5522.     lea    searchstring,a1
  5523.     move.b    (a1),d1
  5524. .fastsearch
  5525.     cmp.b    (a0)+,d1
  5526.     beq.b    .firstfound
  5527. .fastnextchar
  5528.     subq.l    #1,d0                ;dbf bara word!!
  5529.     bne.b    .fastsearch
  5530.     bra.W    searchnotfound
  5531. .firstfound
  5532.     move.l    a0,a2
  5533.     subq.l    #1,a2
  5534.     move.l    a1,a3
  5535.     move.w    searchlen(pc),d2
  5536.     subq.w    #1,d2
  5537.     bmi.b    .found
  5538. .allsearch
  5539.     cmpm.b    (a2)+,(a3)+
  5540.     bne.b    .fastnextchar
  5541.     dbf    d2,.allsearch
  5542. .found
  5543.     subq.l    #1,a0
  5544.     bra.w    searchfound
  5545. .case
  5546.     move.l    a0,a3
  5547.     lea    searchstring,a2
  5548.     move.b    (a2),d0
  5549.     base    util
  5550.     call    ToUpper
  5551.     move.l    d0,d2
  5552.     call    ToLower
  5553.     move.l    d0,d1
  5554.     move.l    a3,a0
  5555.     move.l    fileaddr(pc),d0
  5556.     add.l    filelen(pc),d0
  5557.     sub.l    a0,d0
  5558.     beq.w    searchnotfound
  5559.     move.l    a2,a1
  5560. .cfastsearch
  5561.     cmp.b    (a0),d1
  5562.     beq.b    .cfirstfound
  5563.     cmp.b    (a0),d2
  5564.     beq.b    .cfirstfound
  5565. .cfastnextchar
  5566.     addq.l    #1,a0
  5567.     subq.l    #1,d0
  5568.     bne.b    .cfastsearch
  5569.     bra.w    searchnotfound
  5570. .cfirstfound
  5571.     move.l    a0,a2
  5572.     move.l    a1,a3
  5573.     move.l    d0,d3
  5574.     move.l    d1,d4
  5575.     moveq    #0,d0
  5576.     move.w    searchlen(pc),d0
  5577.     call    Strnicmp
  5578.     tst.l    d0
  5579.     beq.b    .cfound
  5580.     move.l    a2,a0
  5581.     move.l    a3,a1
  5582.     move.l    d3,d0
  5583.     move.l    d4,d1
  5584.     bra.b    .cfastnextchar
  5585. .cfound
  5586.     move.l    a2,a0
  5587.     add.w    searchlen(pc),a2
  5588.     bra.w    searchfound
  5589.  
  5590. ;in:
  5591. * a0    start of text
  5592. * a1    end of text
  5593. searchmarkfound:
  5594.     pushm    d0-d1/a0-a3
  5595.     move.l    a0,a2
  5596.     move.l    a1,a3
  5597.     bsr    getline
  5598.     subq.l    #1,d0
  5599.     move.l    d0,foundlinestart
  5600.     bsr    gotoline
  5601.  
  5602.     moveq    #0,d1
  5603.     sub.l    a0,a2
  5604.     move.l    a2,d0
  5605.     beq.b    .4
  5606.     subq.l    #1,d0
  5607.     lea    tabbar,a1
  5608. .1
  5609.     cmp.b    #TAB,(a0)+
  5610.     bne.b    .2
  5611.     move.b    (a1,d1.w),d1
  5612.     bra.b    .3
  5613. .2
  5614.     addq.l    #1,d1
  5615. .3
  5616.     dbf    d0,.1
  5617. .4
  5618.     move.w    d1,foundcolstart
  5619.  
  5620.     move.l    a3,a0
  5621.     bsr    getline
  5622.     subq.l    #1,d0
  5623.     move.l    d0,foundlineend
  5624.     bsr    gotoline
  5625.     sub.l    a0,a3
  5626.     move.l    a3,d0
  5627.     bne.b    .notwholeline
  5628.     move.l    linelen(pc),a0
  5629.     add.l    foundlineend(pc),a0
  5630.     move.b    (a0),d0
  5631.     move.w    d0,foundcolend
  5632.     bra.b    .exit
  5633. .notwholeline
  5634.     subq.l    #1,d0
  5635.     moveq    #0,d1
  5636.     lea    tabbar,a1
  5637. .11
  5638.     cmp.b    #TAB,(a0)+
  5639.     bne.b    .12
  5640.     move.b    (a1,d1.w),d1
  5641.     bra.b    .13
  5642. .12
  5643.     addq.l    #1,d1
  5644. .13
  5645.     dbf    d0,.11
  5646.     move.w    d1,foundcolend
  5647. .exit
  5648.     popm    d0-d1/a0-a3
  5649.     rts
  5650.  
  5651. foundlinestart:    dc.l    0
  5652. foundlineend:    dc.l    0
  5653. foundcolstart:    dc.w    0
  5654. foundcolend:    dc.w     0
  5655.  
  5656. searchprev:
  5657.     tst.l    filelen
  5658.     beq.s    .exit
  5659.     tst.b    searchstring
  5660.     beq.w    searchnotfound
  5661.     Message    searching
  5662.     tst.w    search_wild
  5663.     beq.s    .nowild
  5664.     bsr    searchwildprev
  5665.     bra.s    .exit
  5666. .nowild
  5667.     bsr    searchnowildprev
  5668. .exit
  5669.     Message    screentitle
  5670.     moveq    #0,d0
  5671.     rts
  5672.  
  5673. searchnowildprev:
  5674.     move.l    linepos(pc),d0
  5675.     bsr.w    gotoline
  5676.     tst.w    search_case
  5677.     beq.B    .case
  5678.     move.l    fileaddr(pc),d0
  5679.     sub.l    a0,d0
  5680.     neg.l    d0
  5681.     beq.w    searchnotfound
  5682.     lea    searchstring,a1
  5683.     move.b    (a1),d1
  5684. .fastsearch
  5685.     cmp.b    -(a0),d1
  5686.     beq.b    .firstfound
  5687. .fastnextchar
  5688.     subq.l    #1,d0
  5689.     bne.b    .fastsearch
  5690.     dbf    d0,.fastsearch
  5691.     bra.w    searchnotfound
  5692. .firstfound
  5693.     move.l    a0,a2
  5694.     move.l    a1,a3
  5695.     move.w    searchlen(pc),d2
  5696.     subq.w    #1,d2
  5697.     bmi.b    .found
  5698. .allsearch
  5699.     cmpm.b    (a2)+,(a3)+
  5700.     bne.b    .fastnextchar
  5701.     dbf    d2,.allsearch
  5702. .found
  5703.     bra.w    searchfound
  5704. .case
  5705.     move.l    a0,a3
  5706.     lea    searchstring,a2
  5707.     move.b    (a2),d0
  5708.     base    util
  5709.     call    ToUpper
  5710.     move.l    d0,d2
  5711.     call    ToLower
  5712.     move.l    d0,d1
  5713.     move.l    a3,a0
  5714.     move.l    fileaddr(pc),d0
  5715.     sub.l    a0,d0
  5716.     neg.l    d0
  5717.     beq.w    searchnotfound
  5718.     move.l    a2,a1
  5719.     subq.l    #1,a0
  5720. .cfastsearch
  5721.     cmp.b    (a0),d1
  5722.     beq.b    .cfirstfound
  5723.     cmp.b    (a0),d2
  5724.     beq.b    .cfirstfound
  5725. .cfastnextchar
  5726.     subq.l    #1,a0
  5727.     subq.l    #1,d0
  5728.     bne.b    .cfastsearch
  5729.     bra.w    searchnotfound
  5730. .cfirstfound
  5731.     move.l    a0,a2
  5732.     move.l    a1,a3
  5733.     move.l    d0,d3
  5734.     move.l    d1,d4
  5735.     moveq    #0,d0
  5736.     move.w    searchlen(pc),d0
  5737.     call    Strnicmp
  5738.     tst.l    d0
  5739.     beq.b    .cfound
  5740.     move.l    a2,a0
  5741.     move.l    a3,a1
  5742.     move.l    d3,d0
  5743.     move.l    d4,d1
  5744.     bra.b    .cfastnextchar
  5745. .cfound
  5746.     move.l    a2,a0
  5747.     add.w    searchlen(pc),a2
  5748.     bra.w    searchfound
  5749.  
  5750. searchwildnext:
  5751.     move.l    linepos(pc),d0
  5752.     addq.l    #1,d0
  5753.     bsr    gotoline
  5754.  
  5755.     move.l    fileaddr(pc),d0
  5756.     add.l    filelen(pc),d0
  5757.     sub.l    a0,d0
  5758.     beq.w    searchnotfound
  5759.  
  5760.     lea    searchstring,a0
  5761.     lea    temp,a1
  5762.     move.b    #"#",(a1)+
  5763.     move.b    #"?",(a1)+
  5764. .copystr
  5765.     move.b    (a0)+,(a1)+
  5766.     bne.s    .copystr
  5767.     move.b    #"#",-1(a1)
  5768.     move.b    #"?",(a1)+
  5769.     clr.b    (a1)
  5770.  
  5771.     tst.w    search_case
  5772.     bne.s    .casesens1
  5773.     lea    temp,a2                ;V37 bugfix
  5774.     base    util
  5775. .toupper
  5776.     move.b    (a2),d0
  5777.     beq.s    .upperready
  5778.     call    ToUpper
  5779.     move.b    d0,(a2)+
  5780.     bra.s    .toupper
  5781. .upperready
  5782. .casesens1
  5783.     base    dos
  5784.     move.l    #temp,d1
  5785.     move.l    #temp+84,d2
  5786.     move.l    #84*2+2,d3
  5787.     tst.w    search_case
  5788.     bne.s    .casesens2
  5789.     call    ParsePatternNoCase
  5790.     bra.s    .parsed
  5791. .casesens2
  5792.     call    ParsePattern
  5793. .parsed
  5794. ;    tst.l    d0
  5795. ;    beq    searchnowildnext        ;fanns inget wildcard!
  5796.     cmp.l    #-1,d0
  5797.     beq    searchnotfound            ;fel
  5798.  
  5799.     move.l    linepos(pc),d7
  5800.     moveq    #0,d6
  5801. .loop
  5802.     addq.l    #1,d7
  5803.     cmp.l    lines(pc),d7
  5804.     bhs    searchnotfound
  5805.  
  5806.     move.l    d7,d0
  5807.     bsr    gotoline
  5808.     move.l    a0,a2
  5809.  
  5810.  
  5811.     move.l    linelen(pc),a1
  5812.     add.l    d7,a1
  5813.     moveq    #0,d0
  5814.     move.b    (a1),d0
  5815.     move.l    d0,d6
  5816.     beq    .loop
  5817.     subq.w    #1,d0
  5818.     lea    temp+256,a1
  5819. .copysearchstring
  5820.     move.b    (a0)+,(a1)+
  5821.     dbf    d0,.copysearchstring
  5822.     clr.b    (a1)
  5823.     move.l    #temp+84,d1
  5824.     move.l    #temp+256,d2
  5825.     tst.w    search_case
  5826.     bne.s    .casesens3
  5827.     call    MatchPatternNoCase
  5828.     bra.s    .tested
  5829. .casesens3
  5830.     call    MatchPattern
  5831. .tested
  5832.     tst.l    d0
  5833.     beq.s    .loop
  5834.  
  5835.     move.l    a2,a0
  5836.     bra.w    searchfound
  5837.  
  5838. searchwildprev:
  5839.     move.l    linepos(pc),d0
  5840.     bsr.w    gotoline
  5841.     move.l    fileaddr(pc),d0
  5842.     sub.l    a0,d0
  5843.     neg.l    d0
  5844.     beq.w    searchnotfound
  5845.  
  5846.     lea    searchstring,a0
  5847.     lea    temp,a1
  5848.     move.b    #"#",(a1)+
  5849.     move.b    #"?",(a1)+
  5850. .copystr
  5851.     move.b    (a0)+,(a1)+
  5852.     bne.s    .copystr
  5853.     move.b    #"#",-1(a1)
  5854.     move.b    #"?",(a1)+
  5855.     clr.b    (a1)
  5856.  
  5857.     tst.w    search_case
  5858.     bne.s    .casesens1
  5859.     lea    temp,a2                ;V37 bugfix
  5860.     base    util
  5861. .toupper
  5862.     move.b    (a2),d0
  5863.     beq.s    .upperready
  5864.     call    ToUpper
  5865.     move.b    d0,(a2)+
  5866.     bra.s    .toupper
  5867. .upperready
  5868. .casesens1
  5869.     base    dos
  5870.     move.l    #temp,d1
  5871.     move.l    #temp+84,d2
  5872.     move.l    #84*2+2,d3
  5873.     tst.w    search_case
  5874.     bne.s    .casesens2
  5875.     call    ParsePatternNoCase
  5876.     bra.s    .parsed
  5877. .casesens2
  5878.     call    ParsePattern
  5879. .parsed
  5880. ;    tst.l    d0
  5881. ;    beq    searchnowildnext        ;fanns inget wildcard!
  5882.     cmp.l    #-1,d0
  5883.     beq    searchnotfound            ;fel
  5884.  
  5885.     move.l    linepos(pc),d7
  5886.     moveq    #0,d6
  5887. .loop
  5888.     subq.l    #1,d7
  5889.     bmi    searchnotfound
  5890.  
  5891.     move.l    d7,d0
  5892.     bsr    gotoline
  5893.     move.l    a0,a2
  5894.  
  5895.     move.l    linelen(pc),a1
  5896.     add.l    d7,a1
  5897.     moveq    #0,d0
  5898.     move.b    (a1),d0
  5899.     move.l    d0,d6
  5900.     beq    .loop
  5901.     subq.w    #1,d0
  5902.     lea    temp+256,a1
  5903. .copysearchstring
  5904.     move.b    (a0)+,(a1)+
  5905.     dbf    d0,.copysearchstring
  5906.     clr.b    (a1)
  5907.     move.l    #temp+84,d1
  5908.     move.l    #temp+256,d2
  5909.     tst.w    search_case
  5910.     bne.s    .casesens3
  5911.     call    MatchPatternNoCase
  5912.     bra.s    .tested
  5913. .casesens3
  5914.     call    MatchPattern
  5915. .tested
  5916.     tst.l    d0
  5917.     beq.s    .loop
  5918.  
  5919.     move.l    a2,a0
  5920.     bra.w    searchfound
  5921.  
  5922. **** screen/environment functions
  5923.  
  5924. iconify:
  5925.     base    icon
  5926.     lea    .defappiconname(pc),a0
  5927.     call    GetDiskObject
  5928.     lea    .diskobject(pc),a0
  5929.     move.l    d0,(a0)
  5930.  
  5931.     base    exec
  5932.     call    CreateMsgPort
  5933.     move.l    d0,d7
  5934.     beq.W    .nomsgport
  5935.     base    wb
  5936.     move.l    .diskobject(pc),d0
  5937.     move.l    d0,a3
  5938.     bne.b    .usedefappicon
  5939.     lea    AppIconDO,a3    ;diskobj
  5940. .usedefappicon
  5941.     moveq    #0,d0        ;id
  5942.     moveq    #0,d1        ;userdata
  5943.     lea    programname(pc),a0
  5944.     move.l    d7,a1        ;msgport
  5945.     suba.l    a2,a2        ;lock
  5946.     suba.l    a4,a4
  5947.     call    AddAppIconA
  5948.     move.l    d0,d6
  5949.     beq.W    .noicon
  5950.  
  5951.     bsr.w    closeenvironment
  5952.  
  5953. .waitloop
  5954.     base    exec
  5955.  
  5956.     move.l    comport,a0
  5957.     move.b    MP_SIGBIT(a0),d1
  5958.     moveq    #0,d0
  5959.     bset    d1,d0
  5960.     lea    .comsignal(pc),a0
  5961.     move.l    d0,(a0)
  5962.  
  5963.     move.l    d7,a0
  5964.     move.b    MP_SIGBIT(a0),d1
  5965.     moveq    #0,d0
  5966.     bset    d1,d0
  5967.     lea    .appsignal(pc),a0
  5968.     move.l    d0,(a0)
  5969.  
  5970.     move.l    .comsignal(pc),d0
  5971.     or.l    .appsignal(pc),d0
  5972.  
  5973.     call    Wait
  5974.  
  5975.     move.l    d0,d1
  5976.     and.l    .appsignal,d1
  5977.     bne.b    .nextmsg
  5978.  
  5979.     move.l    d0,d1
  5980.     and.l    .comsignal,d1
  5981.     beq.b    .waitloop
  5982.     bsr    .doubleclicked
  5983.     bsr    handleCOM
  5984.     moveq    #1,d0
  5985.     rts
  5986. .nextmsg
  5987.     base    exec
  5988.     move.l    d7,a0
  5989.     call    GetMsg
  5990.     tst.l    d0
  5991.     beq.B    .waitloop
  5992.     move.l    d0,a1
  5993.     move.l    am_NumArgs(a1),d2
  5994.     call    ReplyMsg
  5995.     tst.l    d2
  5996.     beq.B    .doubleclicked
  5997.     base    intui
  5998.     suba.l    a0,a0
  5999.     call    DisplayBeep
  6000.     bra.B    .nextmsg
  6001. .doubleclicked
  6002.     base    wb
  6003.     move.l    d6,a0
  6004.     call    RemoveAppIcon
  6005.     bsr.b    .cleanup
  6006.     bsr.w    changevideomode
  6007.     tst.l    d0
  6008.     bne.b    .exit
  6009.     moveq    #1,d0            ;inga fler meddelanden!
  6010. .exit
  6011.     rts
  6012. .noicon
  6013.     lea    noworkbench(pc),a1
  6014.     lea    oktext(pc),a2
  6015.     suba.l    a4,a4
  6016.     bsr.w    requester
  6017.     bsr.b    .cleanup
  6018.     moveq    #1,d0            ;inga fler meddelanden!
  6019.     rts
  6020. .cleanup
  6021.     base    exec
  6022. .getallmsg
  6023.     move.l    d7,a0
  6024.     call    GetMsg
  6025.     tst.l    d0
  6026.     beq.B    .nomoremsg
  6027.     move.l    d0,a1
  6028.     call    ReplyMsg
  6029.     bra.B    .getallmsg
  6030. .nomoremsg
  6031.     move.l    d7,a0
  6032.     call    DeleteMsgPort
  6033. .nomsgport
  6034.     base    icon
  6035.     move.l    .diskobject(pc),d0
  6036.     beq.b    .nodefappicon
  6037.     move.l    d0,a0
  6038.     call    FreeDiskObject
  6039. .nodefappicon
  6040.     rts
  6041. .comsignal    dc.l    0
  6042. .appsignal    dc.l    0
  6043. .diskobject    dc.l    0
  6044. .defappiconname
  6045.     dc.b    "ENV:Textread/def_app",0
  6046.     even
  6047. ;in:
  6048. * d1    gammalt sysfont
  6049. * d2    gammalt screenmode
  6050. * d3    gammalt screendepth
  6051. ;ut:
  6052. * d0    NULL eller felkod
  6053. changeenv:
  6054.     pushm    d1-a6
  6055.     cmp.w    sysfont(pc),d1
  6056.     bne.b    .changescreen
  6057.     cmp.l    displayid(pc),d2
  6058.     bne.b    .changescreen
  6059.     cmp.l    screendepth(pc),d3
  6060.     bne.b    .changescreen
  6061.     bra.b    .dontchangescreen
  6062. .changescreen
  6063.     bsr.w    changevideomode
  6064.     tst.l    d0
  6065.     bne.b    .error
  6066. ;    lea    tabbar,a0
  6067. ;    bsr.w    fixatabbar
  6068. ;    bra.b    .exit
  6069. .dontchangescreen
  6070.     lea    tabbar,a0
  6071.     bsr.w    fixatabbar
  6072.  
  6073.     lea    thisfont(pc),a0
  6074.     bsr.w    changefont
  6075.     tst.l    d0
  6076.     beq.b    .fontok
  6077.     lea    topaz8font(pc),a0
  6078.     bsr.w    changefont
  6079.     tst.l    d0
  6080.     bne.b    .error
  6081. .fontok
  6082.     moveq    #FALSE,d0
  6083.     bsr.w    fixafonten
  6084.     bsr    recountlines
  6085.     bsr    updatemenu
  6086.     bsr.w    updatecheckmarks
  6087.  
  6088.     moveq    #0,d0
  6089.     bsr    gotoline
  6090.     bsr.w    textredraw
  6091. .exit
  6092.     moveq    #0,d0
  6093. .error
  6094.     popm    d1-a6
  6095.     rts
  6096.  
  6097. changevideomode:
  6098.     movem.l    d1-a6,-(sp)
  6099.     lea    scrnsysfont+2(pc),a0
  6100.     move.w    sysfont(pc),(a0)
  6101.     bsr.w    closeenvironment
  6102.     bsr.w    openenvironment
  6103.     tst.l    d0
  6104.     beq.b    .ok
  6105.     lea    displayid(pc),a0
  6106.     move.l    #DEFAULT_MONITOR_ID!HIRES_KEY,(a0);ok.. std hires, sysfont=0
  6107.     lea    screendepth(pc),a0
  6108.     move.l    #2,(a0)
  6109.     lea    scrnsysfont(pc),a0
  6110.     clr.l    (a0)
  6111.     lea    sysfont(pc),a0
  6112.     clr.w    (a0)
  6113.     bsr.w    closeenvironment
  6114.     bsr.w    openenvironment
  6115.     tst.l    d0
  6116.     bne.b    .failure        ;skit i det då!
  6117. .ok
  6118.     moveq    #TRUE,d0
  6119.     bsr    fixafonten
  6120.     bsr    updatemenu
  6121.     bsr.w    updatecheckmarks
  6122.     base    intui
  6123.     move.l    screenptr(pc),a0
  6124.     call    ScreenToFront
  6125.     bsr    recountlines
  6126.     bsr.w    textredraw        ;Uppdatera skärm och gadgetar
  6127.     moveq    #0,d0
  6128. .failure
  6129.     movem.l    (sp)+,d1-a6
  6130.     rts
  6131.  
  6132. savefont:    ;a0=8 bytes buffer,a1=31 bytes namnbuffer
  6133.     move.l    windowptr(pc),a3
  6134.     move.l    wd_RPort(a3),a3
  6135.     move.l    rp_Font(a3),a3
  6136.     move.l    LN_NAME(a3),a2
  6137.     move.l    a1,(a0)+
  6138.     move.w    #30,d0
  6139. .copyname
  6140.     move.b    (a2)+,(a1)+
  6141.     dbeq    d0,.copyname
  6142.     move.l    tf_YSize(a3),(a0)+    ;YSize, Style & Flags
  6143.     rts
  6144. changefont:    ;byter font till TextAttr i a0
  6145.     move.l    a0,a2
  6146.     base    gfx
  6147.     move.l    myfont(pc),d0
  6148.     beq.b    .nofont
  6149.     move.l    d0,a1
  6150.     call    CloseFont
  6151.     lea    myfont(pc),a1
  6152.     clr.l    (a1)
  6153. .nofont
  6154.     tst.l    diskfontbase
  6155.     bne.b    .diskfontok
  6156.     base    exec
  6157.     lea    diskfontname(pc),a1
  6158.     moveq    #37,d0
  6159.     call    OpenLibrary        ;öppna diskfont
  6160.     lea    diskfontbase(pc),a0    ;Det är ju inte nödvändigt med
  6161.     move.l    d0,(a0)            ;diskfont.library... alltså:
  6162.     bne.B    .diskfontok
  6163.     base    gfx
  6164.     move.l    a2,a0
  6165.     call    OpenFont
  6166.     bra.b    .fontopened
  6167. .diskfontok
  6168.     base    diskfont
  6169.     move.l    a2,a0
  6170.     call    OpenDiskFont
  6171. .fontopened
  6172.     lea    myfont(pc),a0
  6173.     move.l    d0,(a0)
  6174.     beq.w    .error
  6175.     base    gfx
  6176.     move.l    windowptr(pc),a1
  6177.     move.l    wd_RPort(a1),a1
  6178.     move.l    d0,a0
  6179.     call    SetFont
  6180.     lea    thisfont(pc),a0
  6181.     lea    thisfontname(pc),a1
  6182.     move.l    a1,(a0)+
  6183.     move.l    4(a2),(a0)+
  6184.     move.w    #30,d0
  6185.     move.l    (a2),a0
  6186. .copyname
  6187.     move.b    (a0)+,(a1)+
  6188.     dbeq    d0,.copyname
  6189.  
  6190.     move.l    myfont(pc),a0
  6191.     moveq    #0,d0
  6192.     move.w    tf_XSize(a0),d0
  6193.     lea    fontx(pc),a1
  6194.     move.l    (a1),d1                    ;-> d1
  6195.     move.l    d0,(a1)
  6196.     move.w    tf_YSize(a0),d0
  6197.     lea    fonty(pc),a1
  6198.     move.l    d0,(a1)
  6199.  
  6200.     move.l    pwidth(pc),d0
  6201.     divu.w    fontx+2(pc),d0
  6202.     and.l    #$ffff,d0
  6203.     lea    cwidth(pc),a0
  6204.     move.l    d0,(a0)
  6205.     mulu.w    fontx+2(pc),d0
  6206.     lea    cwidthp(pc),a0
  6207.     move.l    d0,(a0)
  6208.  
  6209.     move.l    pheight(pc),d0
  6210.     sub.l    barheight(pc),d0
  6211.     sub.l    fonty(pc),d0
  6212.     subq.l    #4,d0                    ;plats för bevelbox
  6213.     divu.w    fonty+2(pc),d0
  6214.     and.l    #$ffff,d0
  6215.     lea    cheight(pc),a0
  6216.     move.l    d0,(a0)
  6217.     mulu.w    fonty+2(pc),d0
  6218.     lea    cheightp(pc),a0
  6219.     move.l    d0,(a0)
  6220.  
  6221. ;    cmp.l    fontx(pc),d1                ;<- d1
  6222. ;    beq.b    .samex
  6223. ;    bsr    countlines                ;width was changed!
  6224. ;.samex
  6225.     base    exec
  6226.     move.l    radpos(pc),d0
  6227.     beq.b    .noradpos
  6228.     move.l    d0,a1
  6229.     call    FreeVec
  6230. .noradpos
  6231.     move.l    cheight(pc),d0
  6232.     lsl.l    #2,d0
  6233.     moveq    #MEMF_ANY,d1
  6234.     call    AllocVec
  6235.     lea    radpos(pc),a0
  6236.     move.l    d0,(a0)
  6237.     beq.b    .error
  6238.     move.l    d0,a0
  6239.     move.l    plane0(pc),d1
  6240.     move.l    bwidth(pc),d2
  6241.     mulu.w    fonty+2(pc),d2
  6242.     move.l    cheight(pc),d0
  6243.     subq.w    #1,d0
  6244. .loop
  6245.     move.l    d1,(a0)+
  6246.     add.l    d2,d1
  6247.     dbf    d0,.loop
  6248.  
  6249.     moveq    #0,d0
  6250.     rts
  6251. .error
  6252.     moveq    #err_nofont,d0
  6253.     rts
  6254.  
  6255. ;in:
  6256. * a0    tabbar (256 bytes buffert)
  6257. fixatabbar:
  6258.     move.l    tabsize(pc),d1
  6259.     move.w    d1,d4
  6260.     subq    #1,d1
  6261.     move.w    #255,d2        ;max radlängd?
  6262.     moveq    #0,d3
  6263. .loop1
  6264.     move.w    d1,d0
  6265.     add.b    d4,d3
  6266.     bne.B    .loop2
  6267.     moveq    #-1,d3        ;om 256, ta 255 istället...
  6268. .loop2
  6269.     move.b    d3,(a0)+
  6270.     dbf    d0,.loop2
  6271.     sub.w    d4,d2
  6272.     cmp.w    d1,d2
  6273.     bpl.B    .loop1
  6274.     rts
  6275.  
  6276. ;in:
  6277. * d0    TRUE: force update ; FALSE: Only update if different font
  6278. fixafonten:        ;fixar font-data. Om inte fonten är 8*8 öppnas
  6279.             ;topaz.font 8 ROM-fonten.
  6280.     tst.l    d0
  6281.     beq.b    .dontforceupdate
  6282.     lea    oldfontsize(pc),a0
  6283.     clr.w    (a0)
  6284. .dontforceupdate
  6285.     tst.w    legalprint
  6286.     beq.w    .fast
  6287.  
  6288.     lea    .minmax(pc),a0
  6289.     bsr    getfontlimits
  6290.  
  6291.     move.l    windowptr(pc),a2
  6292.     move.l    wd_RPort(a2),a2
  6293.  
  6294.     move.w    rp_TxHeight(a2),d1
  6295.     move.w    rp_TxWidth(a2),d1
  6296.  
  6297.     move.w    .minmax+2(pc),d0
  6298.     cmp.w    rp_TxHeight(a2),d0
  6299.     bhi.b    .change            ;<min?
  6300.     move.w    .minmax+6(pc),d0
  6301.     cmp.w    rp_TxHeight(a2),d0
  6302.     blo.b    .change            ;>max?
  6303.  
  6304.     move.w    .minmax(pc),d0
  6305.     cmp.w    rp_TxWidth(a2),d0
  6306.     bhi.b    .change            ;<min?
  6307.     move.w    .minmax+4(pc),d0
  6308.     cmp.w    rp_TxWidth(a2),d0
  6309.     blo.b    .change            ;>max?
  6310.     bra.w    .exit
  6311. .change
  6312.     lea    topaz8font(pc),a0
  6313.     moveq    #0,d0
  6314.     bsr.w    changefont
  6315.     tst.l    d0
  6316.     bne.w    .error
  6317.     bra.w    .exit
  6318. .minmax
  6319.     dc.w    8,8,8,8
  6320. .fast
  6321. .again
  6322.     lea    temp,a5
  6323.     move.w    #255,d0
  6324. .fixfonttable
  6325.     move.b    d0,(a5,d0.w)
  6326.     dbf    d0,.fixfonttable
  6327.     
  6328.     base    gfx
  6329.     move.l    windowptr(pc),a2
  6330.     move.l    wd_RPort(a2),a2
  6331.     move.l    plane0(pc),a3
  6332.     lea    font,a4
  6333.  
  6334.     move.l    barheight(pc),d4
  6335.     add.w    rp_TxBaseline(a2),d4
  6336.  
  6337.     cmp.w    #8,rp_TxHeight(a2)
  6338.     bne.w    .no88
  6339.     cmp.w    #8,rp_TxWidth(a2)
  6340.     bne.w    .no88
  6341.  
  6342.     bsr    issamefont        ;if same font, no need to rebuild it
  6343.     tst.l    d0
  6344.     bne    .exit
  6345.  
  6346.     move.l    a2,a1            ;initera rätta färger!
  6347.     moveq    #1,d0
  6348.     call    SetAPen
  6349.     move.l    a2,a1
  6350.     moveq    #0,d0
  6351.     call    SetBPen
  6352.  
  6353.     move.l    a2,a1
  6354.     moveq    #0,d0
  6355.     move.l    d4,d1
  6356.     call    Move
  6357.  
  6358.     lea    (a5),a0
  6359.     tst.w    nofontfake
  6360.     bne.b    .notfaked00
  6361.     move.l    a2,a1
  6362.     moveq    #0,d0
  6363.     call    SetAPen
  6364.     move.l    a2,a1
  6365.     moveq    #1,d0
  6366.     call    SetBPen
  6367.     lea    $40(a5),a0        ;inv 40 = 00
  6368. .notfaked00
  6369.     move.l    a2,a1
  6370.     moveq    #32,d0
  6371.     call    Text
  6372.     move.l    a2,a1
  6373.     moveq    #1,d0
  6374.     call    SetAPen
  6375.     move.l    a2,a1
  6376.     moveq    #0,d0
  6377.     call    SetBPen
  6378.     move.l    a2,a1
  6379.     lea    $20(a5),a0
  6380.     moveq    #32,d0
  6381.     call    Text
  6382.     bsr.w    .copytext
  6383.     move.l    a2,a1
  6384.     moveq    #0,d0
  6385.     move.l    d4,d1
  6386.     call    Move
  6387.     move.l    a2,a1
  6388.     lea    $40(a5),a0
  6389.     moveq    #64,d0
  6390.     call    Text
  6391.     bsr.W    .copytext
  6392.  
  6393.     move.l    a2,a1
  6394.     moveq    #0,d0
  6395.     move.l    d4,d1
  6396.     call    Move
  6397.  
  6398.     lea    $80(a5),a0
  6399.     tst.w    nofontfake
  6400.     bne.b    .notfaked80
  6401.     move.l    a2,a1
  6402.     moveq    #0,d0
  6403.     call    SetAPen
  6404.     move.l    a2,a1
  6405.     moveq    #1,d0
  6406.     call    SetBPen
  6407.     lea    $c0(a5),a0        ;inv c0 = 80
  6408. .notfaked80
  6409.     move.l    a2,a1
  6410.     moveq    #32,d0
  6411.     call    Text
  6412.     move.l    a2,a1
  6413.     moveq    #1,d0
  6414.     call    SetAPen
  6415.     move.l    a2,a1
  6416.     moveq    #0,d0
  6417.     call    SetBPen
  6418.     move.l    a2,a1
  6419.     lea    $a0(a5),a0
  6420.     moveq    #32,d0
  6421.     call    Text
  6422.     bsr.B    .copytext
  6423.  
  6424.     move.l    a2,a1
  6425.     moveq    #0,d0
  6426.     move.l    d4,d1
  6427.     call    Move
  6428.     move.l    a2,a1
  6429.     moveq    #0,d0
  6430.     move.l    d4,d1
  6431.     call    Move
  6432.     move.l    a2,a1
  6433.     lea    $c0(a5),a0
  6434.     moveq    #64,d0
  6435.     call    Text
  6436.     bsr.B    .copytext
  6437. .exit
  6438.     bsr    issamefont
  6439.     tst.l    d0
  6440.     bne.b    .1
  6441.  
  6442.     bsr.w    freegadgets
  6443.     bsr.w    creategadgets
  6444.     tst.l    d0
  6445.     bne.b    .error
  6446. .1
  6447.     moveq    #0,d0
  6448. .error
  6449.     lea    oldfontsize(pc),a1
  6450.     move.w    thisfontsize(pc),(a1)
  6451.     lea    thisfontname(pc),a0
  6452.     lea    oldfontname,a1
  6453. .copyfontname
  6454.     move.b    (a0)+,(a1)+
  6455.     bne.b    .copyfontname
  6456.     rts
  6457. .no88
  6458.     lea    topaz8font(pc),a0
  6459.     moveq    #0,d0
  6460.     bsr.w    changefont
  6461.     tst.l    d0
  6462.     bne.w    .error
  6463.     bra.w    .again
  6464.  
  6465. .copytext
  6466.     moveq    #63,d0
  6467.     moveq    #0,d2
  6468.     move.l    bwidth(pc),d3
  6469. .nextchar
  6470.     move.l    a3,a0
  6471.     add.l    d2,a0
  6472.     addq.l    #1,d2
  6473.     moveq    #7,d1
  6474. .copychar
  6475.     move.b    (a0),(a4)+
  6476.     clr.b    (a0)
  6477.     add.l    d3,a0
  6478.     dbf    d1,.copychar
  6479.     dbf    d0,.nextchar
  6480.     rts
  6481.  
  6482. ;ut:
  6483. * d0    TRUE if the same font, else FALSE.
  6484. issamefont:
  6485.     move.w    oldfontsize(pc),d0
  6486.     beq.b    .change
  6487.     cmp.w    thisfontsize(pc),d0
  6488.     bne.w    .change
  6489.  
  6490.     lea    thisfontname(pc),a0
  6491.     lea    oldfontname,a1
  6492. .nextchar
  6493.     move.b    (a0)+,d0
  6494.     beq.b    .exit
  6495.     cmp.b    (a1)+,d0
  6496.     beq.b    .nextchar
  6497. .change
  6498.     moveq    #FALSE,d0
  6499.     dc.w    $0c40
  6500. .exit
  6501.     moveq    #TRUE,d0
  6502.     rts
  6503.  
  6504. topaz8font:
  6505.     dc.l    .name
  6506.     dc.w    8
  6507.     dc.b    0
  6508.     dc.b    FPF_ROMFONT!FPF_DESIGNED
  6509. .name
  6510.     dc.b    "topaz.font",0
  6511.     even
  6512.  
  6513. openlibs:
  6514.     lea    _SysBase(pc),a0
  6515.     move.l    4.w,(a0)
  6516.  
  6517.     base    exec
  6518.     lea    intuiname(pc),a1
  6519.     move.l    a1,a2
  6520.     moveq    #37,d0
  6521.     move.l    d0,d2
  6522.     call    OpenLibrary        ;öppna intuition
  6523.     lea    intuibase(pc),a0
  6524.     move.l    d0,(a0)
  6525.     beq.w    .error
  6526.  
  6527.     lea    gfxname(pc),a1
  6528.     move.l    a1,a2
  6529.     moveq    #37,d0
  6530.     move.l    d0,d2
  6531.     call    OpenLibrary        ;öppna gfx
  6532.     lea    gfxbase(pc),a0
  6533.     move.l    d0,(a0)
  6534.     beq.w    .error
  6535.     lea    dosname(pc),a1
  6536.     move.l    a1,a2
  6537.     moveq    #37,d0
  6538.     move.l    d0,d2
  6539.     call    OpenLibrary        ;öppna dos
  6540.     lea    dosbase(pc),a0
  6541.     move.l    d0,(a0)
  6542.     beq.w    .error
  6543.     lea    gadtoolsname(pc),a1
  6544.     move.l    a1,a2
  6545.     moveq    #37,d0
  6546.     move.l    d0,d2
  6547.     call    OpenLibrary        ;öppna gadtools
  6548.     lea    gtbase(pc),a0
  6549.     move.l    d0,(a0)
  6550.     beq.w    .error
  6551.     lea    aslname(pc),a1
  6552.     move.l    a1,a2
  6553.     moveq    #37,d0
  6554.     move.l    d0,d2
  6555.     call    OpenLibrary        ;öppna asl
  6556.     lea    aslbase(pc),a0
  6557.     move.l    d0,(a0)
  6558.     beq.w    .error
  6559.     lea    wbname(pc),a1
  6560.     move.l    a1,a2
  6561.     moveq    #37,d0
  6562.     move.l    d0,d2
  6563.     call    OpenLibrary        ;öppna workbench
  6564.     lea    wbbase(pc),a0
  6565.     move.l    d0,(a0)
  6566.     beq.B    .error
  6567.     lea    iconname(pc),a1
  6568.     move.l    a1,a2
  6569.     moveq    #37,d0
  6570.     move.l    d0,d2
  6571.     call    OpenLibrary        ;öppna icon
  6572.     lea    iconbase(pc),a0
  6573.     move.l    d0,(a0)
  6574.     beq.B    .error
  6575.     lea    utilname(pc),a1
  6576.     move.l    a1,a2
  6577.     moveq    #37,d0
  6578.     move.l    d0,d2
  6579.     call    OpenLibrary        ;öppna utility
  6580.     lea    utilbase(pc),a0
  6581.     move.l    d0,(a0)
  6582.     beq.B    .error
  6583.  
  6584.     lea    xpkname(pc),a1
  6585.     move.l    a1,a2
  6586.     moveq    #0,d0
  6587.     move.l    d0,d2
  6588.     call    OpenLibrary        ;öppna xpk
  6589.     lea    xpkbase(pc),a0
  6590.     move.l    d0,(a0)
  6591.     bne.b    .filelibsopened
  6592.                
  6593.     lea    ppname(pc),a1
  6594.     move.l    a1,a2
  6595.     moveq    #35,d0
  6596.     move.l    d0,d2
  6597.     call    OpenLibrary        ;öppna powerpacker, om inte xpk
  6598.     lea    ppbase(pc),a0
  6599.     move.l    d0,(a0)
  6600. ;    beq.B    .error            ;tjahapps. inget funkade. So what?
  6601. .filelibsopened
  6602.  
  6603.     moveq    #0,d0
  6604.     rts
  6605.  
  6606. * a2    library som inte kunde öppnas
  6607. * d2    version
  6608. .error
  6609.     lea    .args(pc),a0
  6610.     move.l    a2,(a0)+
  6611.     move.l    d2,(a0)
  6612.     base    intui
  6613.     move.l    a6,d0
  6614.     beq.b    .errnointui
  6615.     suba.l    a0,a0
  6616.     lea    .strukt(pc),a1
  6617.     suba.l    a2,a2
  6618.     lea    .args(pc),a3
  6619.     call    EasyRequestArgs
  6620.     bra.b    .exit
  6621. .errnointui
  6622.     ALERT    AN_Unknown!AG_OpenLib!AO_Intuition
  6623. .exit
  6624.     moveq    #err_exitnow,d0
  6625.     rts
  6626. .strukt
  6627.     dc.l    .struktend-*
  6628.     dc.l    0
  6629.     dc.l    0
  6630.     dc.l    errnolibtext
  6631.     dc.l    oktext
  6632. .struktend
  6633. .args    dc.l    0,0
  6634.  
  6635. openenvironment:
  6636.     movem.l    d1-a6,-(sp)
  6637.     base    intui
  6638.     lea    screenerrorcode(pc),a0
  6639.     clr.l    (a0)
  6640.     moveq    #err_noscreen,d7
  6641.     suba.l    a0,a0
  6642.     lea    screentags(pc),a1
  6643.     call    OpenScreenTagList
  6644.     lea    screenptr(pc),a0
  6645.     move.l    d0,(a0)
  6646.     beq.w    .error
  6647.     move.l    screenerrorcode(pc),d1
  6648.     bne.w    .error
  6649.  
  6650.     lea    defpalette,a1
  6651.     bsr    getpalette
  6652.  
  6653.     lea    palette(pc),a1
  6654.     bsr    changepalette
  6655.  
  6656.     base    intui
  6657.     move.l    screenptr(pc),a0
  6658.  
  6659.     moveq    #0,d0
  6660.     move.w    sc_Width(a0),d0
  6661.     lea    windowwidth(pc),a1
  6662.     move.l    d0,(a1)
  6663.     lea    pwidth(pc),a1
  6664.     move.l    d0,(a1)            ;pwidth
  6665.  
  6666.     moveq    #0,d0
  6667.     move.b    sc_BarHeight(a0),d0
  6668.     addq.l    #1,d0
  6669.     lea    barheight(pc),a1
  6670.     move.l    d0,(a1)            ;barheight
  6671.  
  6672.     lea    sc_RastPort(a0),a1
  6673.     move.l    rp_BitMap(a1),a1
  6674.     moveq    #0,d0
  6675.     move.w    bm_BytesPerRow(a1),d0
  6676.     lea    bwidth(pc),a2
  6677.     move.l    d0,(a2)            ;bwidth
  6678.  
  6679.     mulu.w    barheight+2(pc),d0
  6680.     add.l    bm_Planes(a1),d0
  6681.     lea    plane0(pc),a1
  6682.     move.l    d0,(a1)
  6683.  
  6684.     moveq    #0,d0
  6685.     move.w    sc_Height(a0),d0
  6686.     lea    windowheight(pc),a1
  6687.     move.l    d0,(a1)
  6688.     lea    pheight(pc),a1
  6689.     move.l    d0,(a1)            ;pheight
  6690.  
  6691.     lea    pwidth(pc),a0        ;för bred skärm?
  6692.     cmp.l    #254*8,(a0)
  6693.     bhi.w    .error
  6694.     lea    pheight(pc),a0        ;för hög skärm?
  6695.     cmp.l    #254*8,(a0)
  6696.     bhi.w    .error
  6697.  
  6698.     move.l    screenptr(pc),a0
  6699.     lea    sc_RastPort(a0),a1
  6700.     move.l    rp_BitMap(a1),a1
  6701.     base    gfx
  6702.     cmp.w    #39,LIB_VERSION(a6)
  6703.     blo.s    .noforeignbitmap
  6704.  
  6705.     lea    foreignbitmap(pc),a2
  6706.     clr.w    (a2)
  6707.     move.l    screenptr(pc),a0
  6708.     lea    sc_RastPort(a0),a0
  6709.     move.l    rp_BitMap(a0),a0
  6710.     moveq    #BMA_FLAGS,d1
  6711.     call    GetBitMapAttr
  6712.     and.l    #BMF_STANDARD,d0
  6713.     bne.b    .noforeignbitmap
  6714.     addq.w    #1,(a2)
  6715.     lea    legalprint(pc),a0
  6716.     move.w    #TRUE,(a0)        ;system rendering ON
  6717.     lea    nofontfake(pc),a0
  6718.     move.w    #TRUE,(a0)        ;always on when legalprint=TRUE
  6719. .noforeignbitmap
  6720.  
  6721.     base    intui
  6722.     lea    windowonscreen(pc),a0
  6723.     move.l    screenptr(pc),(a0)
  6724.  
  6725.     moveq    #err_nowin,d7
  6726.     suba.l    a0,a0
  6727.     lea    windowtags(pc),a1
  6728.     call    OpenWindowTagList    ;öppna fönster 1
  6729.     lea    windowptr(pc),a0
  6730.     move.l    d0,(a0)
  6731.     beq.w    .error
  6732.  
  6733.     lea    deffont,a0
  6734.     lea    deffontname,a1
  6735.     bsr.w    savefont
  6736.  
  6737.     lea    thisfont(pc),a0
  6738.     bsr.w    changefont
  6739.     tst.l    d0
  6740.     beq.b    .fontok
  6741.     lea    topaz8font(pc),a0
  6742.     bsr.w    changefont
  6743.     move.l    d0,d7
  6744.     bne.w    .error
  6745. .fontok
  6746.  
  6747.     base    exec
  6748.     suba.l    a1,a1
  6749.     call    FindTask
  6750.     lea    thistask(pc),a0
  6751.     move.l    d0,(a0)
  6752.     move.l    d0,a0
  6753.     lea    defreqscreen(pc),a1
  6754.     move.l    pr_WindowPtr(a0),(a1)
  6755.     move.l    windowptr(pc),pr_WindowPtr(a0)    ;requestrar på skärmen!
  6756.  
  6757.     base    gt
  6758.     move.l    screenptr(pc),a0
  6759.     lea    tag_done(pc),a1
  6760.     call    GetVisualInfoA        ;skaffa visuell information
  6761.     lea    screenvi(pc),a0
  6762.     move.l    d0,(a0)
  6763.  
  6764.     lea    winmenuerrorcode(pc),a0
  6765.     clr.l    (a0)
  6766.  
  6767.     moveq    #err_nomenu,d7
  6768.     base    gt
  6769.     lea    winmenu(pc),a0
  6770.     lea    winmenutags(pc),a1
  6771.     call    CreateMenusA
  6772.     lea    winmenuptr(pc),a0    ;skapa menyer
  6773.     move.l    d0,(a0)
  6774.     beq.W    .error
  6775.     move.l    winmenuerrorcode(pc),d1
  6776.     bne.W    .error
  6777.  
  6778. ;    move.l    winmenuprt(pc),a0    ;skapa menyer
  6779.     move.l    d0,a0            ;skapa menyer
  6780.     move.l    screenvi(pc),a1
  6781.     lea    .menutags(pc),a2
  6782.     call    LayoutMenusA
  6783.     tst.l    d0
  6784.     beq.W    .error
  6785.  
  6786.     base    intui
  6787.     move.l    windowptr(pc),a0
  6788.     move.l    winmenuptr(pc),a1
  6789.     call    SetMenuStrip
  6790.  
  6791.     moveq    #err_nogadget,d7
  6792.     bsr.w    creategadgets
  6793.     tst.l    d0
  6794.     bne.w    .error
  6795.  
  6796.     moveq    #err_nofilereq,d7
  6797.     lea    .filereqwindow(pc),a0
  6798.     move.l    windowptr(pc),(a0)
  6799.     lea    filereqhgt(pc),a0
  6800.     move.l    pheight(pc),d0
  6801.     mulu    #7,d0
  6802.     lsr.l    #3,d0
  6803.     move.l    d0,(a0)
  6804.     base    asl
  6805.     moveq    #ASL_FileRequest,d0
  6806.     lea    .filereqtags(pc),a0
  6807.     call    AllocAslRequest    
  6808.     lea    filereqptr(pc),a0
  6809.     move.l    d0,(a0)
  6810.     beq.w    .error
  6811.  
  6812.     lea    setname,a0
  6813.     tst.b    (a0)
  6814.     bne.b    .nosetname
  6815.     lea    defsetname(pc),a0
  6816. .nosetname
  6817.     move.l    a0,a2
  6818.     lea    temp,a1
  6819.     move.w    #tempsize-1,d0
  6820. .copysettingsname
  6821.     move.b    (a0)+,(a1)+
  6822.     dbeq    d0,.copysettingsname
  6823.  
  6824.     base    dos
  6825.     move.l    #temp,d1
  6826.     call    PathPart
  6827.     move.l    d0,a0
  6828.     clr.b    (a0)
  6829.     lea    .setfreqpathpart(pc),a0
  6830.     move.l    #temp,(a0)
  6831.  
  6832.     move.l    a2,d1                ;setname/defsetname!
  6833.     call    FilePart
  6834.     lea    .setfreqfilepart(pc),a0
  6835.     move.l    d0,(a0)
  6836.     move.l    d0,a0
  6837.  
  6838.     moveq    #err_nofilereq,d7
  6839.     lea    .setfreqwindow(pc),a0
  6840.     move.l    windowptr(pc),(a0)
  6841.     lea    setfreqhgt(pc),a0
  6842.     move.l    pheight(pc),d0
  6843.     mulu    #7,d0
  6844.     lsr.l    #3,d0
  6845.     move.l    d0,(a0)
  6846.     base    asl
  6847.     moveq    #ASL_FileRequest,d0
  6848.     lea    .setfreqtags(pc),a0
  6849.     call    AllocAslRequest    
  6850.     lea    setfreqptr(pc),a0
  6851.     move.l    d0,(a0)
  6852.     beq.s    .error
  6853.  
  6854. ;    jsr     SetupScreen        ;GTBX
  6855.     moveq    #0,d7
  6856. .error
  6857.     move.l    d7,d0
  6858.     movem.l    (sp)+,d1-a6
  6859.     rts
  6860. .menutags
  6861.     dc.l    GTMN_NewLookMenus,TRUE
  6862.     dc.l    TAG_DONE
  6863.  
  6864. .setfreqtags
  6865.     dc.l    ASLFR_Window
  6866. .setfreqwindow
  6867.     dc.l    0
  6868.     dc.l    ASLFR_DoPatterns,TRUE
  6869.     dc.l    ASLFR_SleepWindow,TRUE
  6870.     dc.l    ASLFR_InitialFile
  6871. .setfreqfilepart
  6872.     dc.l    0
  6873.     dc.l    ASLFR_InitialDrawer
  6874. .setfreqpathpart
  6875.     dc.l    0
  6876.     dc.l    ASLFR_InitialPattern,.setfreqpat
  6877.     dc.l    TAG_DONE
  6878. .setfreqpat
  6879.     dc.b    "#?.prefs",0
  6880.     even
  6881. .filereqtags:
  6882.     dc.l    ASLFR_Window
  6883. .filereqwindow:
  6884.     dc.l    0
  6885.     dc.l    ASLFR_DoPatterns,TRUE
  6886.     dc.l    ASLFR_SleepWindow,TRUE
  6887.     dc.l    TAG_DONE
  6888.  
  6889. setfreqtags:
  6890.     dc.l    ASLFR_InitialHeight
  6891. setfreqhgt:
  6892.     dc.l    100
  6893.     dc.l    ASLFR_DoSaveMode
  6894. setfreqsave:
  6895.     dc.l    FALSE
  6896.     dc.l    ASLFR_TitleText
  6897. setfreqtitle:
  6898.     dc.l    0
  6899.     dc.l    TAG_DONE
  6900.     even
  6901.  
  6902. filereqtags:
  6903.     dc.l    ASLFR_InitialFile,filename
  6904.     dc.l    ASLFR_InitialDrawer,filereqdir
  6905.     dc.l    ASLFR_InitialPattern,filereqpat
  6906.     dc.l    ASLFR_InitialHeight
  6907. filereqhgt:
  6908.     dc.l    100
  6909.     dc.l    ASLFR_DoSaveMode
  6910. filereqsave:
  6911.     dc.l    FALSE
  6912.     dc.l    ASLFR_TitleText
  6913. filereqtitle:
  6914.     dc.l    0
  6915.     dc.l    TAG_DONE
  6916.  
  6917. closeenvironment:
  6918.     movem.l    d1-a6,-(sp)
  6919. ;    jsr    CloseDownScreen        ;GTBX
  6920.     base    asl
  6921.     move.l    setfreqptr(pc),a0
  6922.     clr.l    setfreqptr
  6923.     call    FreeAslRequest
  6924. .nosetfreq
  6925.     move.l    filereqptr(pc),a0
  6926.     clr.l    filereqptr
  6927.     call    FreeAslRequest
  6928. .nofilereq
  6929.     base    intui
  6930.     move.l    windowptr(pc),d0
  6931.     move.l    d0,a0
  6932.     beq.B    .nowindow_menu
  6933.     call    ClearMenuStrip
  6934. .nowindow_menu
  6935.     move.l    thistask(pc),d0
  6936.     beq.b    .nodefreq
  6937.     move.l    d0,a0
  6938.     move.l    defreqscreen(pc),pr_WindowPtr(a0)
  6939. .nodefreq
  6940.     base    exec
  6941.     call    Forbid
  6942.     base    gt
  6943. .nextmsg
  6944.     move.l    windowptr(pc),d0
  6945.     move.l    d0,a0
  6946.     beq.B    .nowindow
  6947.  
  6948.     move.l    wd_UserPort(a0),a0
  6949.     call    GT_GetIMsg
  6950.     tst.l    d0
  6951.     beq.b    .nullmsg
  6952.     move.l    d0,a1
  6953.     call    GT_ReplyIMsg
  6954.     bra.b    .nextmsg
  6955. .nullmsg
  6956.     base    intui
  6957.     move.l    windowptr(pc),a0
  6958.     call    CloseWindow
  6959.     lea    windowptr(pc),a0
  6960.     clr.l    (a0)
  6961. .nowindow
  6962.     base    exec
  6963.     call    Permit
  6964.  
  6965.     base    gt
  6966.     move.l    winmenuptr(pc),d0
  6967.     move.l    d0,a0
  6968.     beq.B    .nowinmenu
  6969.     call    FreeMenus
  6970.     lea    winmenuptr(pc),a0
  6971.     clr.l    (a0)
  6972. .nowinmenu
  6973.     bsr.w    freegadgets
  6974.     move.l    gtbase(pc),a6
  6975.     move.l    screenvi(pc),d0
  6976.     move.l    d0,a0
  6977.     beq.B    .noscreenvi
  6978.     call    FreeVisualInfo
  6979.     lea    screenvi(pc),a0
  6980.     clr.l    (a0)
  6981. .noscreenvi
  6982.     move.l    intuibase(pc),a6
  6983.     move.l    screenptr(pc),d0
  6984.     move.l    d0,a0
  6985.     beq.B    .noscreen
  6986.     call    CloseScreen
  6987.     lea    screenptr(pc),a0
  6988.     clr.l    (a0)
  6989. .noscreen
  6990.     base    gfx
  6991.     move.l    myfont(pc),d0
  6992.     beq.b    .nofont
  6993.     move.l    d0,a1
  6994.     call    CloseFont
  6995.     lea    myfont(pc),a0
  6996.     clr.l    (a0)
  6997. .nofont
  6998.     base    exec
  6999.     move.l    radpos(pc),d0
  7000.     beq.b    .noradpos
  7001.     move.l    d0,a1
  7002.     call    FreeVec
  7003.     lea    radpos(pc),a0
  7004.     clr.l    (a0)
  7005. .noradpos
  7006.     movem.l    (sp)+,d1-a6
  7007.     moveq    #0,d0
  7008.     rts
  7009. closelibs:
  7010.     base    exec
  7011.     move.l    xpkbase(pc),d0
  7012.     beq.B    .noxpkbase
  7013.     move.l    d0,a1
  7014.     call    CloseLibrary
  7015.     lea    xpkbase(pc),a0
  7016.     clr.l    (a0)
  7017. .noxpkbase
  7018.     move.l    ppbase(pc),d0
  7019.     beq.B    .noppbase
  7020.     move.l    d0,a1
  7021.     call    CloseLibrary
  7022.     lea    ppbase(pc),a0
  7023.     clr.l    (a0)
  7024. .noppbase
  7025.     move.l    utilbase(pc),d0
  7026.     beq.B    .noutilbase
  7027.     move.l    d0,a1
  7028.     call    CloseLibrary
  7029.     lea    utilbase(pc),a0
  7030.     clr.l    (a0)
  7031. .noutilbase
  7032.     move.l    iconbase(pc),d0
  7033.     beq.B    .noiconbase
  7034.     move.l    d0,a1
  7035.     call    CloseLibrary
  7036.     lea    iconbase(pc),a0
  7037.     clr.l    (a0)
  7038. .noiconbase
  7039.     move.l    diskfontbase(pc),d0
  7040.     beq.B    .nodiskbase
  7041.     move.l    d0,a1
  7042.     call    CloseLibrary
  7043.     lea    diskfontbase(pc),a0
  7044.     clr.l    (a0)
  7045. .nodiskbase
  7046.     move.l    wbbase(pc),d0
  7047.     beq.B    .nowbbase
  7048.     move.l    d0,a1
  7049.     call    CloseLibrary
  7050.     lea    wbbase(pc),a0
  7051.     clr.l    (a0)
  7052. .nowbbase
  7053.     move.l    aslbase(pc),d0
  7054.     beq.B    .noaslbase
  7055.     move.l    d0,a1
  7056.     call    CloseLibrary
  7057.     lea    aslbase(pc),a0
  7058.     clr.l    (a0)
  7059. .noaslbase
  7060.     move.l    gtbase(pc),d0
  7061.     beq.B    .nogtbase
  7062.     move.l    d0,a1
  7063.     call    CloseLibrary
  7064.     lea    gtbase(pc),a0
  7065.     clr.l    (a0)
  7066. .nogtbase
  7067.     move.l    intuibase(pc),d0
  7068.     beq.B    .nointuibase
  7069.     move.l    d0,a1
  7070.     call    CloseLibrary
  7071.     lea    intuibase(pc),a0
  7072.     clr.l    (a0)
  7073. .nointuibase
  7074.     move.l    dosbase(pc),d0
  7075.     beq.B    .nodosbase
  7076.     move.l    d0,a1
  7077.     call    CloseLibrary
  7078.     lea    dosbase(pc),a0
  7079.     clr.l    (a0)
  7080. .nodosbase
  7081.     move.l    gfxbase(pc),d0
  7082.     beq.B    .nogfxbase
  7083.     move.l    d0,a1
  7084.     call    CloseLibrary
  7085.     lea    gfxbase(pc),a0
  7086.     clr.l    (a0)
  7087. .nogfxbase
  7088.     moveq    #0,d0
  7089.     rts
  7090.  
  7091. creategadgets:
  7092.     base    gt
  7093.  
  7094.     lea    top(pc),a2
  7095.     move.l    linepos(pc),(a2)
  7096.     lea    total(pc),a2
  7097.     move.l    lines(pc),(a2)
  7098.     lea    synliga(pc),a2
  7099.     move.l    cheight(pc),(a2)
  7100.  
  7101.     lea    gadgetptr(pc),a0
  7102.     call    CreateContext
  7103.     move.l    d0,d7
  7104.  
  7105.     move.l    fonty(pc),d2
  7106.     addq.l    #3,d2
  7107.  
  7108.     move.l    fontx(pc),d3
  7109.     lsl.l    #1,d3                ;'Q'-knappen
  7110.  
  7111.     move.l    fontx(pc),d4
  7112.     mulu.w    #25+2,d4
  7113. ;    addq.l    #4,d4                ;Statustext
  7114.  
  7115.     lea    newgadget(pc),a1
  7116.     move.l    d3,d0
  7117.     add.l    d4,d0
  7118.     move.w    d0,gng_LeftEdge(a1)
  7119.     move.l    pwidth(pc),d1
  7120.     sub.w    d0,d1
  7121.     ble.w    .error
  7122.     move.w    d1,gng_Width(a1)
  7123.  
  7124.     move.l    windowheight(pc),d0
  7125.     sub.l    d2,d0
  7126.     ble.w    .error
  7127.     move.w    d0,gng_TopEdge(a1)
  7128.     move.w    d2,gng_Height(a1)
  7129.     clr.l    gng_GadgetText(a1)
  7130.     lea    thisfont(pc),a0
  7131.     move.l    a0,gng_TextAttr(a1)
  7132.     move.w    #1,gng_GadgetID(a1)
  7133.     clr.l    gng_Flags(a1)
  7134.     move.l    screenvi(pc),gng_VisualInfo(a1)
  7135.     clr.l    gng_UserData(a1)
  7136.     move.l    d7,a0
  7137.     lea    scrollertags(pc),a2
  7138.     move.l    #SCROLLER_KIND,d0
  7139.     call    CreateGadgetA
  7140.     lea    scrollgadget(pc),a0
  7141.     move.l    d0,(a0)
  7142.     beq.W    .error
  7143.  
  7144.     lea    newgadget(pc),a1
  7145.     move.w    #0,gng_LeftEdge(a1)
  7146.     move.l    d3,d0
  7147.     subq.l    #1,d0
  7148.     move.w    d0,gng_Width(a1)
  7149.     lea    .q(pc),a0
  7150.     move.l    a0,gng_GadgetText(a1)
  7151.     move.w    #2,gng_GadgetID(a1)
  7152.     move.l    scrollgadget(pc),a0
  7153.     lea    tag_done(pc),a2
  7154.     move.l    #BUTTON_KIND,d0
  7155.     call    CreateGadgetA
  7156.     lea    quitgadget(pc),a0
  7157.     move.l    d0,(a0)
  7158.     beq.B    .error
  7159.  
  7160.     lea    .drawtags(pc),a1
  7161.     move.l    screenvi(pc),4(a1)
  7162.     move.l    d3,d0
  7163.     move.l    windowheight(pc),d1
  7164.     sub.l    d2,d1
  7165.     move.l    d2,d3
  7166.     move.l    d4,d2
  7167.     subq.l    #1,d2
  7168.     ble.b    .error
  7169.     move.l    screenptr(pc),a0
  7170.     lea    sc_RastPort(a0),a0
  7171.     call    DrawBevelBoxA
  7172.  
  7173.     base    intui
  7174.     move.l    windowptr(pc),a0
  7175.     move.l    gadgetptr(pc),a1
  7176.     suba.l    a2,a2
  7177.     moveq    #0,d0
  7178.     moveq    #-1,d1
  7179.     call    AddGList
  7180.     move.l    windowptr(pc),a1
  7181.     move.l    gadgetptr(pc),a0
  7182.     suba.l    a2,a2
  7183.     moveq    #-1,d0
  7184.     call    RefreshGList
  7185.     base    gt
  7186.     move.l    windowptr(pc),a0
  7187.     suba.l    a1,a1
  7188.     call    GT_RefreshWindow
  7189.     moveq    #0,d0
  7190.     rts
  7191. .error
  7192.     moveq    #-1,d0
  7193.     rts
  7194. .q
  7195.     dc.b    "Q",0
  7196. .drawtags
  7197.     dc.l    GT_VisualInfo,0
  7198.     dc.l    GTBB_Recessed,TRUE
  7199.     dc.l    TAG_DONE
  7200.  
  7201. changenum:
  7202.     moveq    #4,d0
  7203.     lea    linetext(pc),a0
  7204.     lea    temp,a1
  7205. .loop
  7206.     move.b    (a0)+,(a1)+
  7207.     dbf    d0,.loop
  7208.     move.l    linepos(pc),d0
  7209.     bsr.w    numdec
  7210. .copylinenum
  7211.     move.b    (a0)+,(a1)+
  7212.     bne.b    .copylinenum
  7213.     move.b    #" ",-1(a1)
  7214.  
  7215.     move.l    linepos(pc),d0
  7216.     mulu.w    #100,d0
  7217.     move.l    lines(pc),d1
  7218.     sub.l    cheight(pc),d1
  7219.     beq.b    .nodiv
  7220.     divu.w    d1,d0            ;hmm...
  7221. .nodiv
  7222.     and.l    #$0000ffff,d0
  7223.     bsr.w    numdec
  7224.     addq.l    #7,a0
  7225.     move.b    (a0)+,(a1)+
  7226.     move.b    (a0)+,(a1)+
  7227.     move.b    (a0)+,(a1)+
  7228.     move.b    #"%",(a1)+
  7229.     move.b    #" ",(a1)+
  7230.  
  7231.     moveq    #"W",d0            ;små statusbokstäver
  7232.     tst.w    wordwrap
  7233.     bne.b    .wwyes
  7234.     moveq    #" ",d0
  7235. .wwyes
  7236.     move.b    d0,(a1)+
  7237.     moveq    #"A",d0
  7238.     tst.w    alwaysremansi
  7239.     bne.b    .rayes
  7240.     moveq    #" ",d0
  7241. .rayes
  7242.     move.b    d0,(a1)+
  7243.     moveq    #"C",d0
  7244.     tst.w    alwaysremcr
  7245.     bne.b    .rcyes
  7246.     moveq    #" ",d0
  7247. .rcyes
  7248.     move.b    d0,(a1)+
  7249.     moveq    #"F",d0
  7250.     tst.w    nofontfake
  7251.     bne.b    .nfyes
  7252.     moveq    #" ",d0
  7253. .nfyes
  7254.     move.b    d0,(a1)+
  7255.  
  7256.     move.l    windowheight(pc),d2
  7257.     sub.l    barheight(pc),d2
  7258.     sub.l    fonty(pc),d2
  7259.     subq.l    #1,d2
  7260.  
  7261.     move.l    a1,d3
  7262.     lea    temp,a0
  7263.     sub.l    a0,d3
  7264.     subq.l    #1,d3            ;längd ok!
  7265.     moveq    #3,d1
  7266.     bsr.w    printline
  7267.     rts
  7268.  
  7269. changescroll:
  7270.     base    gt
  7271.     lea    changetop(pc),a0
  7272.     move.l    linepos(pc),(a0)
  7273.     lea    changetotal(pc),a0
  7274.     move.l    lines(pc),(a0)
  7275.     move.l    scrollgadget(pc),a0
  7276.     move.l    windowptr(pc),a1
  7277.     suba.l    a2,a2
  7278.     lea    changescrolltags(pc),a3
  7279.     call    GT_SetGadgetAttrsA
  7280.     rts
  7281. changescrolltags:
  7282.     dc.l    GTSC_Top
  7283. changetop:
  7284.     dc.l    0
  7285.     dc.l    GTSC_Total
  7286. changetotal:
  7287.     dc.l    0
  7288.     dc.l    TAG_DONE
  7289.  
  7290. freegadgets:
  7291.     bsr    unsetwritemask
  7292.  
  7293.     lea.l    gadgetptr(pc),a2
  7294.  
  7295.  
  7296.     base    gfx
  7297.     move.l    windowptr(pc),d0
  7298.     beq.b    .nowin
  7299.     move.l    d0,a1
  7300.     move.l    wd_RPort(a1),a1
  7301.     moveq    #0,d0
  7302.     call    SetRast
  7303.  
  7304.     base    intui
  7305.     move.l    windowptr(pc),a0
  7306.     move.l    (a2),d0
  7307.     beq.b    .nogadget
  7308.     move.l    d0,a1
  7309.     moveq    #-1,d0
  7310.     call    RemoveGList
  7311. .nowin
  7312.     base    gt
  7313.     move.l    (a2),d0
  7314.     beq.b    .nogadget
  7315.     move.l    d0,a0
  7316.     call    FreeGadgets
  7317. .nogadget
  7318.     clr.l    (a2)
  7319.     moveq    #0,d0
  7320.     rts
  7321. scrollertags:
  7322.     dc.l    GTSC_Top
  7323. top:
  7324.     dc.l    0
  7325.     dc.l    GTSC_Total
  7326. total:
  7327.     dc.l    0
  7328.     dc.l    GTSC_Visible
  7329. synliga:
  7330.     dc.l    0
  7331.     dc.l    GTSC_Arrows,16
  7332.     dc.l    TAG_DONE
  7333. newgadget:
  7334.     blk.b    gng_SIZEOF,0
  7335. gadgetptr:    dc.l    0
  7336. scrollgadget:    dc.l    0
  7337. quitgadget:    dc.l    0
  7338.  
  7339. ;in:
  7340. * a1    pointer to ULONG:R0,G0,B0,R1,B1,G1,... table to be filled
  7341. getpalette:
  7342.     move.l    screenptr(pc),d0
  7343.     beq.b    .exit
  7344.     move.l    d0,a2
  7345.     lea    sc_ViewPort(a2),a2
  7346.     move.l    vp_ColorMap(a2),a2
  7347.     base    gfx
  7348.     cmp.w    #39,LIB_VERSION(a6)
  7349.     blo.b    .v36
  7350.     moveq    #0,d0
  7351.     moveq    #2^maxdepth,d1
  7352.     move.l    a2,a0
  7353.     call    GetRGB32
  7354.     bra.b    .exit
  7355. .v36
  7356.     moveq    #0,d2
  7357.     move.l    a1,a3
  7358. .nextcol
  7359.     move.l    d2,d0
  7360.     move.l    a2,a0
  7361.     call    GetRGB4
  7362.     move.w    d0,d1
  7363.     bsr.b    .4to32
  7364.     move.l    d1,8(a3)
  7365.  
  7366.     lsr.w    #4,d0
  7367.     move.w    d0,d1
  7368.     lsr.w    #4,d0
  7369.     bsr.b    .4to32
  7370.     move.l    d1,4(a3)
  7371.  
  7372.     lsr.w    #4,d0
  7373.     move.w    d0,d1
  7374.     bsr.b    .4to32
  7375.     move.l    d1,(a3)
  7376.  
  7377.     add.l    #4*3,a3
  7378.     addq.l    #1,d2
  7379.     cmp.w    #2^maxdepth,d2
  7380.     bne.b    .nextcol
  7381. .exit
  7382.     moveq    #0,d0
  7383.     rts
  7384. ;in:
  7385. * d1    4bit
  7386. ;ut:
  7387. * d1    32bit
  7388. .4to32
  7389.     pushm    d0/d2
  7390.     move.l    d1,d0
  7391.     and.l    #15,d0
  7392.     moveq    #0,d1
  7393.     moveq    #8-1,d2
  7394. .4to32_loop
  7395.     lsl.l    #4,d1
  7396.     or.b    d0,d1
  7397.     dbf    d2,.4to32_loop
  7398.     popm    d0/d2
  7399.     rts
  7400. ;in:
  7401. * a1    pointer to ULONG:R0,G0,B0,R1,B1,G1,... table
  7402. changepalette:
  7403.     move.l    screenptr(pc),d0
  7404.     beq.b    .exit
  7405.     move.l    d0,a2
  7406.     lea    sc_ViewPort(a2),a2
  7407.  
  7408.     base    gfx
  7409.     cmp.w    #39,LIB_VERSION(a6)
  7410.     blo.b    .v36
  7411.     lea    colortable,a0
  7412.     move.l    #(2^maxdepth)<<16!0,(a0)+
  7413.     moveq    #3*(2^maxdepth)-1,d0
  7414. .copylongs
  7415.     move.l    (a1)+,(a0)+
  7416.     dbf    d0,.copylongs
  7417.     clr.l    (a0)
  7418.     move.l    a2,a0
  7419.     lea    colortable,a1
  7420.     call    LoadRGB32
  7421.     bra.b    .exit
  7422. .v36
  7423.     lea    colortable,a0
  7424.     moveq    #(2^maxdepth)-1,d0
  7425. .make4table
  7426.     moveq    #0,d2
  7427.     move.l    (a1)+,d1
  7428.     rol.l    #4,d1
  7429.     and.w    #15,d1
  7430.     or.w    d1,d2
  7431.     lsl.w    #4,d2
  7432.     move.l    (a1)+,d1
  7433.     rol.l    #4,d1
  7434.     and.w    #15,d1
  7435.     or.w    d1,d2
  7436.     lsl.w    #4,d2
  7437.     move.l    (a1)+,d1
  7438.     rol.l    #4,d1
  7439.     and.w    #15,d1
  7440.     or.w    d1,d2
  7441.     move.w    d2,(a0)+
  7442.     dbf    d0,.make4table
  7443.     moveq    #(2^maxdepth),d0
  7444.     move.l    a2,a0
  7445.     lea    colortable,a1
  7446.     call    LoadRGB4
  7447. .exit
  7448.     moveq    #0,d0
  7449.     rts
  7450.  
  7451.  
  7452. **** diverse
  7453.  
  7454. setwritemask:
  7455.     base    gfx
  7456.     move.l    windowptr(pc),d0
  7457.     beq.b    .nowin
  7458.     move.l    d0,a2    
  7459.     move.l    wd_RPort(a2),a2
  7460.  
  7461.     cmp.w    #39,LIB_VERSION(a6)
  7462.     bhs.b    .v39
  7463.     move.b    #%00000001,rp_Mask(a2)
  7464.     bra.b    .writemaskset
  7465. .v39
  7466.     move.l    a2,a0
  7467.     moveq    #1,d0
  7468.     jsr    -990(a6)            ;SetMaxPen (V39)
  7469. .writemaskset
  7470. .nowin
  7471.     rts
  7472. unsetwritemask:
  7473.     base    gfx
  7474.     move.l    windowptr(pc),d0
  7475.     beq.b    .nowin
  7476.     move.l    d0,a2
  7477.     move.l    wd_RPort(a2),a2
  7478.  
  7479.     cmp.w    #39,LIB_VERSION(a6)
  7480.     bhs.b    .v39
  7481.     move.b    #%11111111,rp_Mask(a2)
  7482.     bra.b    .writemaskset
  7483. .v39
  7484.     move.l    a2,a0
  7485.     moveq    #3,d0
  7486.     jsr    -990(a6)            ;SetMaxPen (V39)
  7487. .writemaskset
  7488. .nowin
  7489.     rts
  7490.  
  7491. ;in:
  7492. * a1    meddelande
  7493. * a2    gadget
  7494. * a4    NULL eller pek på argumentlista
  7495. requester:
  7496.     movem.l    d1/a0-a4/a6,-(sp)
  7497.     bsr    lockwindow
  7498.     base    intui
  7499.     lea    .strukttext(pc),a0
  7500.     move.l    a1,(a0)
  7501.     lea    .struktgadget(pc),a0
  7502.     move.l    a2,(a0)
  7503.     move.l    windowptr(pc),a0
  7504.     lea    .strukt(pc),a1
  7505.     suba.l    a2,a2
  7506.     move.l    a4,a3
  7507.     call    EasyRequestArgs
  7508.     bsr    unlockwindow
  7509.     movem.l    (sp)+,d1/a0-a4/a6
  7510.     rts
  7511. .strukt
  7512.     dc.l    .struktend-*
  7513.     dc.l    0
  7514.     dc.l    0
  7515. .strukttext
  7516.     dc.l    0
  7517. .struktgadget
  7518.     dc.l    0
  7519. .struktend
  7520.  
  7521. ;in:
  7522. * a2    Window
  7523. * a3    Gadget
  7524. PressButton:
  7525.     pushm    a2/a6
  7526.     BASE    intui
  7527.     move.l    a2,a0
  7528.     move.l    a3,a1
  7529.     call    RemoveGadget
  7530.     or.w    #GFLG_SELECTED,gg_Flags(a3)
  7531.     or.w    #GACT_TOGGLESELECT,gg_Activation(a3)
  7532.     move.l    a2,a0
  7533.     move.l    a3,a1
  7534.     moveq    #-1,d0
  7535.     call    AddGadget
  7536.     move.l    a3,a0
  7537.     move.l    a2,a1
  7538.     suba.l    a2,a2
  7539.     call    RefreshGadgets
  7540.     BASE    dos
  7541.     moveq    #5,d1
  7542.     call    Delay
  7543.     popm    a2/a6
  7544.     rts
  7545. ;in:
  7546. * d1    string
  7547. * d2    pointer to longword
  7548. strtoulong:        ;exactly like dos.library/StrToLong, but unsigned
  7549.     pushm    d2-d4
  7550.     move.l    d1,a0
  7551.     move.l    d2,a1
  7552.     clr.l    (a1)
  7553.     moveq    #0,d3
  7554.     moveq    #0,d4
  7555. .findfirst
  7556.     move.b    (a0)+,d4
  7557.     cmp.b    #" ",d4
  7558.     beq.b    .findfirst
  7559.     cmp.b    #TAB,d4
  7560.     beq.b    .findfirst
  7561.     sub.b    #"0",d4
  7562.     bmi.b    .error
  7563.     cmp.b    #9,d4
  7564.     bhi.b    .error
  7565. .next
  7566.     move.l    d3,d2
  7567.     asl.l    #3,d3
  7568.     add.l    d2,d3
  7569.     add.l    d2,d3
  7570.     add.l    d4,d3
  7571.     move.b    (a0)+,d4
  7572.     sub.b    #"0",d4
  7573.     bmi.b    .klart
  7574.     cmp.b    #9,d4
  7575.     bls.b    .next
  7576. .klart
  7577.     move.l    d3,(a1)
  7578. .error
  7579.     sub.l    d1,a0
  7580.     move.l    a0,d0
  7581.     subq.l    #2,d0
  7582.     popm    d2-d4
  7583.     rts
  7584.  
  7585. ;in:
  7586. * d0    number
  7587. ;ut:
  7588. * a0    dec string (10 bytes: "       777",0)
  7589. * d0    dec string ("777",0)
  7590. numdec:
  7591.     movem.l    d1-d2/a1-a2/a6,-(sp)
  7592.     base    util
  7593.     lea    numdec_buffert,a2
  7594.     move.l    a2,a0
  7595.     lea    .siffror(pc),a1
  7596.     moveq    #9,d1
  7597. .init
  7598.     move.b    #" ",(a0)+
  7599.     dbf    d1,.init
  7600.     clr.b    (a0)
  7601.     moveq    #9,d2
  7602. .loop
  7603.     moveq    #10,d1
  7604.     call    UDivMod32
  7605.     move.b    (a1,d1.w),-(a0)        ;remainder
  7606.     tst.l    d0
  7607.     beq.b    .klar
  7608.     dbf    d2,.loop
  7609. .klar
  7610.     move.l    a0,d0
  7611.     move.l    a2,a0
  7612.     movem.l    (sp)+,d1-d2/a1-a2/a6
  7613.     rts
  7614. .siffror
  7615.     dc.b    '0123456789'
  7616.  
  7617. cls:
  7618.     tst.w    legalprint
  7619.     bne.b    .system
  7620.  
  7621.     base    gfx
  7622.  
  7623.     call    OwnBlitter
  7624.     call    WaitBlit
  7625.     lea    $dff000,a5
  7626.     move.l    #$01000000,bltcon0(a5)
  7627.     move.l    #-1,bltafwm(a5)
  7628.     move.l    plane0(pc),bltdpt(a5)
  7629.     move.w    #0,bltdmod(a5)
  7630.  
  7631.     move.l    bwidth(pc),d0
  7632.     lsr.l    #1,d0
  7633.     move.l    cheightp(pc),d1
  7634.     btst    #GFXB_BIG_BLITS,gb_ChipRevBits0(a6)
  7635.     bne.b    .bigblit
  7636.     lsl.l    #6,d1
  7637.     or.l    d0,d1
  7638.     move.w    d1,bltsize(a5)
  7639.     bra.b    .blitted
  7640. .bigblit
  7641.     move.w    d1,bltsizv(a5)
  7642.     move.w    d0,bltsizh(a5)
  7643. .blitted
  7644.     call    DisownBlitter
  7645.     call    WaitBlit
  7646.     rts
  7647.  
  7648. .system
  7649.     bsr    setwritemask
  7650.     base    gfx
  7651.     move.l    screenptr(pc),a3
  7652.     lea    sc_RastPort(a3),a3
  7653.     move.l    a3,a1
  7654.     moveq    #0,d0
  7655.     call    SetAPen
  7656.     move.l    a3,a1
  7657.     moveq    #0,d0
  7658.     move.l    barheight(pc),d1
  7659.     move.l    cwidthp(pc),d2
  7660.     move.l    cheightp(pc),d3
  7661.     add.l    d1,d3
  7662.     subq.l    #1,d3
  7663.     call    RectFill
  7664.     call    WaitBlit
  7665.     rts
  7666.  
  7667.  
  7668. ;slavefunc
  7669. ;    lea    .keepgoing(pc),a0
  7670. ;    clr.w    (a0)
  7671. ;    base    exec
  7672. ;    call    CreateMsgPort
  7673. ;    lea    slaveport(pc),a0
  7674. ;    move.l    d0,(a0)
  7675. ;    beq.s    .noport
  7676. ;.loop
  7677. ;    move.l    slaveport(pc),a0
  7678. ;    call    WaitPort
  7679. ;.getallmsgs
  7680. ;    base    exec
  7681. ;    move.l    slaveport(pc),a0
  7682. ;    call    GetMsg
  7683. ;    tst.l    d0
  7684. ;    beq.s    .outofmsgs
  7685. ;    move.l    d0,a1
  7686. ;    move.w    slavecmd(a1),d2
  7687. ;    call    ReplyMsg
  7688. ;
  7689. ;    cmp.w    #-1,d2
  7690. ;    bne.s    .noquit
  7691. ;    lea    .keepgoing(pc),a0
  7692. ;    addq.w    #1,(a0)
  7693. ;    bra.s    .getallmsgs
  7694. ;.noquit
  7695. ;
  7696. ;.outofmsgs
  7697. ;    tst.w    .keepgoing
  7698. ;    beq.s    .loop
  7699. ;
  7700. ;    move.l    slaveport(pc),a0
  7701. ;    call    DeleteMsgPort
  7702. ;.noport
  7703. ;    rts                ;avsluta processen!
  7704. ;.keepgoing
  7705. ;    dc.w    0
  7706. ;
  7707. ;slavesendmsg
  7708. ;    base    exec
  7709. ;    move.l    slaveport(pc),a0
  7710. ;    lea    slavemessage(pc),a1
  7711. ;    move.l    comport(pc),MN_REPLYPORT(a1)
  7712. ;    move.w    #slavemessagelen,MN_LENGTH(a1)
  7713. ;    call    PutMsg
  7714. ;    move.l    comport(pc),a0
  7715. ;    call    WaitPort
  7716. ;.getallcommsgs
  7717. ;    move.l    comport(pc),a0
  7718. ;    call    GetMsg
  7719. ;    tst.l    d0
  7720. ;    bne.s    .getallcommsgs
  7721. ;    rts
  7722. ;slaveport
  7723. ;    dc.l    0
  7724. ;slavemessage
  7725. ;    ds.b    MP_SIZE        ;fult!!
  7726. ;slavecmd        =*-slavemessage
  7727. ;    dc.w    0    ;command
  7728. ;    dc.w    0    ;data
  7729. ;slavemessagelen    =*-slavemessage
  7730.  
  7731.  
  7732. **********************************************
  7733.  
  7734. ;;
  7735. ; Strings:
  7736.  
  7737. abouttext:    dc.b    "Textread release %s, version %s.",10
  7738.         dc.b    "Copyright ©1992-1995 Martin Blom.",10
  7739.         dc.b    10
  7740.         dc.b    "Current textfile: %s (%-ld bytes).",10
  7741.         dc.b    "Total free memory: %-ld bytes.",10
  7742.         dc.b    "Largest block: %-ld bytes.",10
  7743.         dc.b    10
  7744.         dc.b    "This program is shareware.",0
  7745.  
  7746. smodetext:    dc.b    "Please chose a screen mode",0
  7747. smodegadget:    dc.b    "PAL|PAL laced|NTSC|NTSC laced|Productivity|Cancel",0
  7748.  
  7749. savetext    dc.b    "Are you sure you want",10
  7750.         dc.b    "to save the file %s?",0
  7751. savegadget    dc.b    "Save|Cancel",0
  7752.  
  7753. errnomem    dc.b    "Out of memory.",0
  7754. nofileloaded    dc.b    "No text loaded.",0
  7755. noworkbench    dc.b    "Workbench isn't open/loaded.",0
  7756. colerrortext:    dc.b    "Unable to run 'Colors'.",0
  7757. errnofile    dc.b    "Unable to open file.",0
  7758. writeerr    dc.b    "Unable to save file.",0
  7759. savesetmessage:    dc.b    "Unable to save settings",0
  7760. errnolibtext    dc.b    "Unable to open",10
  7761.         dc.b    "%s V%ld+.",0
  7762.  
  7763. openfiletext    dc.b    "Open file",0
  7764. savefiletext    dc.b    "Save file",0
  7765. loadsettitle:    dc.b    "Load settings",0
  7766. savesettitle:    dc.b    "Save settings",0
  7767.  
  7768. loadingtext    dc.b    "Loading...",0
  7769. savingtext    dc.b    "Saving...",0
  7770. searching:    dc.b    "Searching...",0
  7771. counting    dc.b    "Counting lines...",0
  7772. remansitext    dc.b    "Removing ANSI codes...",0
  7773. remcrtext    dc.b    "Removing CR (ascii #13) characters...",0
  7774.  
  7775. menutext    dc.b    "Textread %s - Buffer %lu/%lu: %.31s (%lu lines)",0
  7776. menuemptytext    dc.b    "Textread %s - Buffer %lu/%lu (empty)",0
  7777.  
  7778. screenname:    dc.b    "Textread Screen",0
  7779. intname:    dc.b    "Textread VBLANK server",0
  7780. oktext:        dc.b    "Ok",0
  7781. linetext    dc.b    "Line:",0
  7782.  
  7783.     even
  7784.  
  7785. oldfontsize:    dc.w    0
  7786. foreignbitmap:    dc.w    0
  7787.  
  7788. fileaddr:    dc.l    0
  7789. filelen:    dc.l    0
  7790. filememlen:    dc.l    0
  7791. linepos:    dc.l    0
  7792. lines:        dc.l    1
  7793. linelen:    dc.l    notnull
  7794. linelensize:    dc.l    0
  7795.  
  7796. barheight:    dc.l    0    ;linjer att hoppa innan menyraden är slut
  7797. bwidth:        dc.l    0    ;vidd i bytes
  7798.  
  7799. pwidth:        dc.l    0    ;vidd i pixels
  7800. cwidth:        dc.l    0    ;kolumner (tecken)
  7801. cwidthp:    dc.l    0    ;kolumner (pixels)
  7802.  
  7803. pheight:    dc.l    0    ;höjd i pixels
  7804. cheight:    dc.l    0    ;rader (tecken)
  7805. cheightp:    dc.l    0    ;rader (pixels)
  7806.  
  7807. plane0:        dc.l    0
  7808. radpos:        dc.l    0
  7809.  
  7810. null:        dc.l    0
  7811. notnull:    dc.l    -1
  7812.  
  7813. thistask:    dc.l    0
  7814. ;slave:        dc.l    0
  7815. ;printerslave:    dc.l    0
  7816.  
  7817. aslname:    dc.b    "asl.library",0
  7818. diskfontname:    dc.b    "diskfont.library",0    ;DISKFONTNAME
  7819. dosname:    DOSNAME
  7820. gadtoolsname:    dc.b    "gadtools.library",0
  7821. gfxname:    GRAPHICSNAME
  7822. iconname:    dc.b    "icon.library",0    ;ICONNAME
  7823. intuiname:    dc.b    "intuition.library",0    ;INTNAME
  7824. ppname:        PPNAME
  7825. utilname:    UTILITYNAME
  7826. wbname:        dc.b    "workbench.library",0    ;WORKBENCHNAME
  7827. xpkname:    XPKNAME
  7828.  
  7829. aslbase:    dc.l    0
  7830. _SysBase:    dc.l    0
  7831. diskfontbase:    dc.l    0
  7832. dosbase:    dc.l    0
  7833. _GfxBase:
  7834. gfxbase:    dc.l    0
  7835. _GadToolsBase:
  7836. gtbase:        dc.l    0
  7837. iconbase:    dc.l    0
  7838. _IntuitionBase:
  7839. intuibase:    dc.l    0
  7840. ppbase:        dc.l    0
  7841. _UtilityBase:
  7842. utilbase:    dc.l    0
  7843. wbbase:        dc.l    0
  7844. xpkbase:    dc.l    0
  7845.  
  7846.  
  7847.  
  7848. unit:        dc.l    0
  7849.  
  7850.  
  7851. filereqptr:    dc.l    0
  7852. setfreqptr:    dc.l    0
  7853. setreqptr:    dc.l    0
  7854.  
  7855. screenptr:    dc.l    0
  7856. screenvi:    dc.l    0
  7857. windowptr:    dc.l    0
  7858. winmenuptr:    dc.l    0
  7859. myfont:        dc.l    0
  7860. fontx:        dc.l    0
  7861. fonty:        dc.l    0
  7862.  
  7863. defreqscreen:    dc.l    0
  7864. status:        dc.b    0
  7865.     even
  7866. tag_done:    dc.l    TAG_DONE
  7867.  
  7868. screentags:
  7869.     dc.l    SA_Title,screenname
  7870.     dc.l    SA_DisplayID
  7871. displayid:
  7872.     dc.l    HIRES_KEY
  7873.     dc.l    SA_Depth
  7874. screendepth:
  7875.     dc.l    2
  7876.     dc.l    SA_Overscan,OSCAN_TEXT
  7877.     dc.l    SA_AutoScroll,TRUE
  7878.     dc.l    SA_Pens,notnull
  7879.     dc.l    SA_Behind,TRUE
  7880.     dc.l    SA_ErrorCode,screenerrorcode
  7881.     dc.l    SA_SysFont
  7882. scrnsysfont:
  7883.     dc.l    TRUE
  7884.     dc.l    SA_MinimizeISG,TRUE
  7885.     dc.l    SA_FullPalette,TRUE
  7886.     dc.l    TAG_DONE
  7887. screenerrorcode:
  7888.     dc.l    0
  7889.  
  7890. windowtags:
  7891.     dc.l    WA_RptQueue,1
  7892.     dc.l    WA_Left,0
  7893.     dc.l    WA_Top,0
  7894.     dc.l    WA_Width
  7895. windowwidth:
  7896.     dc.l    640
  7897.     dc.l    WA_Height
  7898. windowheight:
  7899.     dc.l    200
  7900.     dc.l    WA_Title,programname
  7901.     dc.l    WA_CustomScreen
  7902. windowonscreen:
  7903.     dc.l    0
  7904.     dc.l    WA_Backdrop,TRUE
  7905.     dc.l    WA_Borderless,TRUE
  7906.     dc.l    WA_ScreenTitle,screentitle
  7907.     dc.l    WA_SmartRefresh,TRUE
  7908.     dc.l    WA_Activate,TRUE
  7909.     dc.l    WA_IDCMP,IDCMP_INACTIVEWINDOW!IDCMP_MOUSEBUTTONS!IDCMP_MENUVERIFY!IDCMP_MOUSEBUTTONS!ARROWIDCMP!SCROLLERIDCMP!IDCMP_REFRESHWINDOW!IDCMP_MENUPICK!IDCMP_VANILLAKEY!IDCMP_RAWKEY
  7910.     ;se även rutinen "printhelp!!"
  7911.  
  7912.     dc.l    WA_NewLookMenus,TRUE
  7913.     dc.l    TAG_DONE
  7914.  
  7915. winmenutags:
  7916.     dc.l    GTMN_FullMenu,NULL
  7917.     dc.l    GTMN_SecondaryError,winmenuerrorcode
  7918.     dc.l    TAG_DONE
  7919. winmenuerrorcode:
  7920.     dc.l    0
  7921.  
  7922.  
  7923. programname:    dc.b    "Textread",0    ;MUST NOT CHANGE! (used as name for messageport)
  7924. filename:    ds.b    32
  7925.     even
  7926.  
  7927. ;fixa winmenu om man inte kör V39+
  7928. fixwinmenu:
  7929.     base    exec
  7930.     cmp.w    #39,LIB_VERSION(a6)
  7931.     bhs.b    .finished
  7932.     lea    winmenu(pc),a0
  7933. .nextnewmenu
  7934.     cmp.b    #NM_END,gnm_Type(a0)
  7935.     beq.b    .finished
  7936.     move.w    gnm_Flags(a0),d0
  7937.     and.w    #NM_COMMANDSTRING,d0
  7938.     beq.b    .ok
  7939.     and.w    #~NM_COMMANDSTRING,gnm_Flags(a0)
  7940.     clr.l    gnm_CommKey(a0)
  7941. .ok
  7942.     add.w    #gnm_SIZEOF,a0
  7943.     bra.b    .nextnewmenu
  7944. .finished
  7945.     rts
  7946.  
  7947. winmenu:
  7948. * Project
  7949.     dc.b    NM_TITLE,0
  7950.     dc.l    .project
  7951.     dc.l    NULL
  7952.     dc.w    0
  7953.     dc.l    0
  7954.     dc.l    NULL
  7955.  
  7956.     dc.b    NM_ITEM,0
  7957.     dc.l    .new
  7958.     dc.l    .newc
  7959.     dc.w    0
  7960.     dc.l    0
  7961.     dc.l    mnew
  7962.  
  7963.     dc.b    NM_ITEM,0
  7964.     dc.l    .open
  7965.     dc.l    .openc
  7966.     dc.w    0
  7967.     dc.l    0
  7968.     dc.l    mopen
  7969.  
  7970.     dc.b    NM_ITEM,0
  7971.     dc.l    .opennew
  7972.     dc.l    NULL
  7973.     dc.w    0
  7974.     dc.l    0
  7975.     dc.l    mopennew
  7976.  
  7977. * -----
  7978.     dc.b    NM_ITEM,0
  7979.     dc.l    NM_BARLABEL
  7980.     dc.l    NULL
  7981.     dc.w    0
  7982.     dc.l    0
  7983.     dc.l    NULL
  7984.  
  7985.     dc.b    NM_ITEM,0
  7986.     dc.l    .save
  7987.     dc.l    .savec
  7988.     dc.w    0
  7989.     dc.l    0
  7990.     dc.l    msave
  7991.  
  7992.     dc.b    NM_ITEM,0
  7993.     dc.l    .saveas
  7994.     dc.l    .saveasc
  7995.     dc.w    0
  7996.     dc.l    0
  7997.     dc.l    msaveas
  7998. * -----
  7999.     dc.b    NM_ITEM,0
  8000.     dc.l    NM_BARLABEL
  8001.     dc.l    NULL
  8002.     dc.w    0
  8003.     dc.l    0
  8004.     dc.l    NULL
  8005.  
  8006.     dc.b    NM_ITEM,0
  8007.     dc.l    .print
  8008.     dc.l    .printc
  8009.     dc.w    0
  8010.     dc.l    0
  8011.     dc.l    mprint
  8012.  
  8013.     dc.b    NM_ITEM,0
  8014.     dc.l    .printas
  8015.     dc.l    NULL
  8016.     dc.w    0
  8017.     dc.l    0
  8018.     dc.l    mprintas
  8019. * -----
  8020.     dc.b    NM_ITEM,0
  8021.     dc.l    NM_BARLABEL
  8022.     dc.l    NULL
  8023.     dc.w    0
  8024.     dc.l    0
  8025.     dc.l    NULL
  8026.  
  8027.     dc.b    NM_ITEM,0
  8028.     dc.l    .reveal
  8029.     dc.l    .revealc
  8030.     dc.w    0
  8031.     dc.l    0
  8032.     dc.l    mreveal
  8033.  
  8034.     dc.b    NM_ITEM,0
  8035.     dc.l    .close
  8036.     dc.l    .closec
  8037.     dc.w    NM_COMMANDSTRING
  8038.     dc.l    0
  8039.     dc.l    mclose
  8040.  
  8041. * -----
  8042.     dc.b    NM_ITEM,0
  8043.     dc.l    NM_BARLABEL
  8044.     dc.l    NULL
  8045.     dc.w    0
  8046.     dc.l    0
  8047.     dc.l    NULL
  8048.  
  8049.     dc.b    NM_ITEM,0
  8050.     dc.l    .iconify
  8051.     dc.l    .iconifyc
  8052.     dc.w    0
  8053.     dc.l    0
  8054.     dc.l    miconify
  8055.  
  8056.     dc.b    NM_ITEM,0
  8057.     dc.l    .workbench
  8058.     dc.l    NULL
  8059.     dc.w    0
  8060.     dc.l    0
  8061.     dc.l    NULL
  8062.  
  8063.     dc.b    NM_SUB,0
  8064.     dc.l    .openwb
  8065.     dc.l    NULL
  8066.     dc.w    0
  8067.     dc.l    0
  8068.     dc.l    mopenwb
  8069.  
  8070.     dc.b    NM_SUB,0
  8071.     dc.l    .closewb
  8072.     dc.l    NULL
  8073.     dc.w    0
  8074.     dc.l    0
  8075.     dc.l    mclosewb
  8076.  
  8077. * -----
  8078.     dc.b    NM_ITEM,0
  8079.     dc.l    NM_BARLABEL
  8080.     dc.l    NULL
  8081.     dc.w    0
  8082.     dc.l    0
  8083.     dc.l    NULL
  8084.  
  8085.     dc.b    NM_ITEM,0
  8086.     dc.l    .about
  8087.     dc.l    .aboutc
  8088.     dc.w    0
  8089.     dc.l    0
  8090.     dc.l    mabout
  8091.  
  8092. * -----
  8093.     dc.b    NM_ITEM,0
  8094.     dc.l    NM_BARLABEL
  8095.     dc.l    NULL
  8096.     dc.w    0
  8097.     dc.l    0
  8098.     dc.l    NULL
  8099.  
  8100.     dc.b    NM_ITEM,0
  8101.     dc.l    .quit
  8102.     dc.l    .quitc
  8103.     dc.w    0
  8104.     dc.l    0
  8105.     dc.l    mquit
  8106.  
  8107. * Settings
  8108.     dc.b    NM_TITLE,0
  8109.     dc.l    .settings
  8110.     dc.l    NULL
  8111.     dc.w    0
  8112.     dc.l    0
  8113.     dc.l    NULL
  8114.  
  8115.     dc.b    NM_ITEM,0
  8116.     dc.l    .wordwrap
  8117.     dc.l    .wordwrapc
  8118.     dc.w    CHECKIT!MENUTOGGLE!CHECKED!NM_COMMANDSTRING
  8119.     dc.l    0
  8120.     dc.l    mwordwrap
  8121.  
  8122.     dc.b    NM_ITEM,0
  8123.     dc.l    .sysfont
  8124.     dc.l    NULL
  8125.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8126.     dc.l    0
  8127.     dc.l    msysfont
  8128.  
  8129.     dc.b    NM_ITEM,0
  8130.     dc.l    .alwaysremansi
  8131.     dc.l    NULL
  8132.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8133.     dc.l    0
  8134.     dc.l    malwaysremansi
  8135.  
  8136.     dc.b    NM_ITEM,0
  8137.     dc.l    .alwaysremcr
  8138.     dc.l    NULL
  8139.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8140.     dc.l    0
  8141.     dc.l    malwaysremcr
  8142.  
  8143.     dc.b    NM_ITEM,0
  8144.     dc.l    .nofontfake
  8145.     dc.l    NULL
  8146.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8147.     dc.l    0
  8148.     dc.l    mnofontfake
  8149.  
  8150.     dc.b    NM_ITEM,0
  8151.     dc.l    .legalprint
  8152.     dc.l    NULL
  8153.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8154.     dc.l    0
  8155.     dc.l    mlegalprint
  8156.  
  8157.     dc.b    NM_ITEM,0
  8158.     dc.l    .fontcheck
  8159.     dc.l    NULL
  8160.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8161.     dc.l    0
  8162.     dc.l    mfontcheck
  8163.  
  8164. * -----
  8165.     dc.b    NM_ITEM,0
  8166.     dc.l    NM_BARLABEL
  8167.     dc.l    NULL
  8168.     dc.w    0
  8169.     dc.l    0
  8170.     dc.l    NULL
  8171.  
  8172.     dc.b    NM_ITEM,0
  8173.     dc.l    .tabsize
  8174.     dc.l    .tabsizec
  8175.     dc.w    NM_COMMANDSTRING
  8176.     dc.l    0
  8177.     dc.l    mtabsize
  8178.  
  8179.     dc.b    NM_ITEM,0
  8180.     dc.l    .screen
  8181.     dc.l    NULL
  8182.     dc.w    0
  8183.     dc.l    0
  8184.     dc.l    mscreen
  8185.  
  8186.     dc.b    NM_ITEM,0
  8187.     dc.l    .colour
  8188.     dc.l    NULL
  8189.     dc.w    0
  8190.     dc.l    0
  8191.     dc.l    NULL
  8192.  
  8193.     dc.b    NM_SUB,0
  8194.     dc.l    .screencol
  8195.     dc.l    NULL
  8196.     dc.w    0
  8197.     dc.l    0
  8198.     dc.l    mscreencol
  8199.  
  8200.     dc.b    NM_SUB,0
  8201.     dc.l    .defcol
  8202.     dc.l    NULL
  8203.     dc.w    0
  8204.     dc.l    0
  8205.     dc.l    mdefcol
  8206.  
  8207.     dc.b    NM_ITEM,0
  8208.     dc.l    .font
  8209.     dc.l    NULL
  8210.     dc.w    0
  8211.     dc.l    0
  8212.     dc.l    NULL
  8213.  
  8214.     dc.b    NM_SUB,0
  8215.     dc.l    .textfont
  8216.     dc.l    NULL
  8217.     dc.w    0
  8218.     dc.l    0
  8219.     dc.l    mtextfont
  8220.  
  8221.     dc.b    NM_SUB,0
  8222.     dc.l    .deffont
  8223.     dc.l    NULL
  8224.     dc.w    0
  8225.     dc.l    0
  8226.     dc.l    mdeffont
  8227.  
  8228. * -----
  8229.     dc.b    NM_ITEM,0
  8230.     dc.l    NM_BARLABEL
  8231.     dc.l    NULL
  8232.     dc.w    0
  8233.     dc.l    0
  8234.     dc.l    NULL
  8235.  
  8236.     dc.b    NM_ITEM,0
  8237.     dc.l    .loadset
  8238.     dc.l    NULL
  8239.     dc.w    0
  8240.     dc.l    0
  8241.     dc.l    mloadset
  8242.  
  8243.     dc.b    NM_ITEM,0
  8244.     dc.l    .saveset
  8245.     dc.l    NULL
  8246.     dc.w    0
  8247.     dc.l    0
  8248.     dc.l    msaveset
  8249.  
  8250.     dc.b    NM_ITEM,0
  8251.     dc.l    .savesetas
  8252.     dc.l    NULL
  8253.     dc.w    0
  8254.     dc.l    0
  8255.     dc.l    msavesetas
  8256.  
  8257. * -----
  8258.     dc.b    NM_ITEM,0
  8259.     dc.l    NM_BARLABEL
  8260.     dc.l    NULL
  8261.     dc.w    0
  8262.     dc.l    0
  8263.     dc.l    NULL
  8264.  
  8265.     dc.b    NM_ITEM,0
  8266.     dc.l    .createicons
  8267.     dc.l    NULL
  8268.     dc.w    CHECKIT!MENUTOGGLE!CHECKED
  8269.     dc.l    0
  8270.     dc.l    mcreateicons
  8271.  
  8272.     dc.b    NM_ITEM,0
  8273.     dc.l    .prefs2all
  8274.     dc.l    NULL
  8275.     dc.w    0
  8276.     dc.l    0
  8277.     dc.l    mprefs2all
  8278.  
  8279. * Commands
  8280.     dc.b    NM_TITLE,0
  8281.     dc.l    .commands
  8282.     dc.l    NULL
  8283.     dc.w    0
  8284.     dc.l    0
  8285.     dc.l    NULL
  8286.  
  8287.     dc.b    NM_ITEM,0
  8288.     dc.l    .searchfor
  8289.     dc.l    .searchforc
  8290.     dc.w    0
  8291.     dc.l    0
  8292.     dc.l    msearch
  8293.  
  8294.     dc.b    NM_ITEM,0
  8295.     dc.l    .searchsnext
  8296.     dc.l    .searchsnextc
  8297.     dc.w    NM_COMMANDSTRING
  8298.     dc.l    0
  8299.     dc.l    msearchnext
  8300.  
  8301.     dc.b    NM_ITEM,0
  8302.     dc.l    .searchsprev
  8303.     dc.l    .searchsprevc
  8304.     dc.w    NM_COMMANDSTRING
  8305.     dc.l    0
  8306.     dc.l    msearchprev
  8307.  
  8308. * -----
  8309.     dc.b    NM_ITEM,0
  8310.     dc.l    NM_BARLABEL
  8311.     dc.l    NULL
  8312.     dc.w    0
  8313.     dc.l    0
  8314.     dc.l    NULL
  8315.  
  8316.     dc.b    NM_ITEM,0
  8317.     dc.l    .gotoline
  8318.     dc.l    .gotolinec
  8319.     dc.w    NM_COMMANDSTRING
  8320.     dc.l    0
  8321.     dc.l    vl
  8322.  
  8323.     dc.b    NM_ITEM,0
  8324.     dc.l    .gotopercent
  8325.     dc.l    .gotopercentc
  8326.     dc.w    NM_COMMANDSTRING
  8327.     dc.l    0
  8328.     dc.l    vg
  8329. * -----
  8330.     dc.b    NM_ITEM,0
  8331.     dc.l    NM_BARLABEL
  8332.     dc.l    NULL
  8333.     dc.w    0
  8334.     dc.l    0
  8335.     dc.l    NULL
  8336.  
  8337.     dc.b    NM_ITEM,0
  8338.     dc.l    .edittext
  8339.     dc.l    .edittextc
  8340.     dc.w    NM_COMMANDSTRING
  8341.     dc.l    0
  8342.     dc.l    medittext
  8343.  
  8344.     dc.b    NM_ITEM,0
  8345.     dc.l    .remansi
  8346.     dc.l    .remansic
  8347.     dc.w    NM_COMMANDSTRING
  8348.     dc.l    0
  8349.     dc.l    mremansi
  8350.  
  8351.     dc.b    NM_ITEM,0
  8352.     dc.l    .remcr
  8353.     dc.l    .remcrc
  8354.     dc.w    NM_COMMANDSTRING
  8355.     dc.l    0
  8356.     dc.l    mremcr
  8357. * END
  8358.     dc.b    NM_END,0
  8359.     dc.l    0
  8360.     dc.l    NULL
  8361.     dc.w    0
  8362.     dc.l    0
  8363.     dc.l    NULL
  8364.  
  8365. .project    dc.b    "Project",0
  8366. .new        dc.b        "New",0
  8367. .open        dc.b        "Open...",0
  8368. .opennew    dc.b        "Open new...",0
  8369. .save        dc.b        "Save...",0
  8370. .saveas        dc.b        "Save As...",0
  8371. .print        dc.b        "Print",0
  8372. .printas    dc.b        "Print as...",0
  8373. .iconify    dc.b        "Iconify",0
  8374. .reveal        dc.b        "Reveal...",0
  8375. .close        dc.b        "Close",0
  8376. .workbench    dc.b            "Workbench",0
  8377. .openwb        dc.b            "Open",0
  8378. .closewb    dc.b            "Close",0
  8379. .about        dc.b        "About...",0
  8380. .quit        dc.b        "Quit Textread",0
  8381. .settings    dc.b    "Settings",0
  8382. .wordwrap    dc.b        "Wrap words?",0
  8383. .sysfont    dc.b        "Use Sysfont?",0
  8384. .alwaysremansi    dc.b        "Auto-remove ANSIs?",0
  8385. .alwaysremcr    dc.b        "Auto-remove CRs?",0
  8386. .nofontfake    dc.b        "Don't 'fake' font?",0
  8387. .legalprint    dc.b        "System rendering?",0
  8388. .fontcheck    dc.b        "Check fonts?",0
  8389. .tabsize    dc.b        "Tab size...",0
  8390. .screen         dc.b        "Screen mode...",0
  8391. .colour        dc.b        "Screen colours",0
  8392. .screencol    dc.b            "Select screen colours...",0
  8393. .defcol        dc.b            "Default colours",0
  8394. .font        dc.b        "Text font",0
  8395. .textfont    dc.b            "Select text font...",0
  8396. .deffont    dc.b            "Default font",0
  8397. .loadset    dc.b        "Load settings...",0
  8398. .saveset    dc.b        "Save settings",0
  8399. .savesetas    dc.b        "Save settings as...",0
  8400. .createicons    dc.b        "Create icons?",0
  8401. .prefs2all    dc.b        "Copy to all buffers",0
  8402. .commands    dc.b    "Commands",0
  8403. .searchfor    dc.b        "Find...",0
  8404. .searchsnext    dc.b        "Find next",0
  8405. .searchsprev    dc.b        "Find previous",0
  8406. .gotoline    dc.b        "Go to line...",0
  8407. .gotopercent    dc.b        "Go to percent...",0
  8408. .edittext    dc.b        "Edit text",0
  8409. .remansi    dc.b        "Remove ANSIs",0
  8410. .remcr        dc.b        "Remove CRs",0
  8411.  
  8412. .newc        dc.b    "N",0
  8413. .openc        dc.b    "O",0
  8414. .savec        dc.b    "S",0
  8415. .saveasc    dc.b    "A",0
  8416. .printc        dc.b    "P",0
  8417. .revealc    dc.b    "R",0
  8418. .closec        dc.b    "Esc",0
  8419. .iconifyc    dc.b    "I",0
  8420. .aboutc        dc.b    "?",0
  8421. .quitc        dc.b    "Q",0
  8422.  
  8423. .wordwrapc    dc.b    "W",0
  8424. .tabsizec    dc.b    "Tab",0
  8425.  
  8426. .searchforc    dc.b    "F",0
  8427. .searchsnextc    dc.b    "N",0
  8428. .searchsprevc    dc.b    "P",0
  8429. .gotolinec    dc.b    "#/L",0
  8430. .gotopercentc    dc.b    "%/G",0
  8431. .edittextc    dc.b    "Shift E",0
  8432. .remansic    dc.b    "Shift A",0
  8433. .remcrc        dc.b    "Shift C",0
  8434.     even
  8435.  
  8436. ***
  8437. ;;
  8438. settings:
  8439.  
  8440. filereqdir:        dc.b    "SYS:",0
  8441.             blk.b    256-(*-filereqdir),0
  8442. filereqpat:        dc.b    "~(#?.info)",0
  8443.             blk.b    64-(*-filereqpat),0
  8444. clcwidth:        dc.l    0        ;countlines' cwidth
  8445.  
  8446. prefs2all_start:
  8447. prefs2all_offset    =prefs2all_start-settings
  8448.  
  8449. thisfont:        dc.l    thisfontname
  8450. thisfontsize:        dc.w    8
  8451.             dc.b    0,FPF_ROMFONT!FPF_DESIGNED
  8452. thisfontname:        dc.b    "topaz.font",0
  8453.             blk.b    31-(*-thisfontname),0
  8454.  
  8455.         even
  8456.  
  8457. tabsize:        dc.l    8
  8458.  
  8459. * --- Checkmarks ---
  8460. setwordwrap:        dc.w    1
  8461. setsysfont:        dc.w    0
  8462. setalwaysremansi:    dc.w    0
  8463. setalwaysremcr:     dc.w    0
  8464. setnofontfake:        dc.w    1
  8465. setlegalprint:        dc.w    1
  8466. setcreateicons:        dc.w    1
  8467. setfontcheck:        dc.w    1
  8468.  
  8469. setdisplayid:        dc.l    HIRES_KEY
  8470. setscreendepth:        dc.l    2
  8471.  
  8472. palette:
  8473.             dc.l    $AAAAAAAA,$AAAAAAAA,$AAAAAAAA
  8474.             dc.l    $00000000,$00000000,$00000000
  8475.             dc.l    $FFFFFFFF,$FFFFFFFF,$FFFFFFFF
  8476.             dc.l    $66666666,$88888888,$BBBBBBBB
  8477.             dc.l    $00000000,$00000000,$00000000
  8478.             dc.l    $00000000,$00000000,$00000000
  8479.             dc.l    $00000000,$00000000,$00000000
  8480.             dc.l    $00000000,$00000000,$00000000
  8481. prefs2all_end:
  8482. prefs2all_len        =prefs2all_end-prefs2all_start
  8483.  
  8484. settings_len        =*-settings
  8485.  
  8486. pol:        dc.l    1
  8487. pom:        dc.l    1
  8488. por:        dc.l    2
  8489. pow:        dc.l    TRUE
  8490. pob:        dc.l    TRUE
  8491. poi:        dc.l    FALSE
  8492. pou:        dc.l    TRUE
  8493. mptab:        dc.l    8
  8494. mppage:        dc.w    0
  8495. mpww:        dc.b    0
  8496. mpinfo:        dc.b    1        ;header on/off
  8497. mpheader:    dc.b    5,1,4,3        ;#0=fet #1=kursiv #2=understr
  8498.                     ;1=filnamn 2=titel 3=sidnummer 4=datum
  8499. mptitle:    blk.b    32,0        ;30 tecken + 1 nolla + jämt!
  8500.  
  8501. defsetname:    dc.b    "ENVARC:Textread/Textread.prefs",0
  8502.     even
  8503.  
  8504.  
  8505. **** muti-buffer structure
  8506.  
  8507.     RSRESET
  8508.     rs.b        LN_SIZE        ;node
  8509. buff_commessageport:    rs.l    1
  8510. buff_fileaddr:        rs.l    1
  8511. buff_filelen:        rs.l    1
  8512. buff_filememlen:    rs.l    1
  8513. buff_linepos:        rs.l    1
  8514. buff_lines:        rs.l    1
  8515. buff_linelen:        rs.l    1
  8516. buff_linelensize:    rs.l    1
  8517. buff_number        rs.b    4    ; 'xx: ', requestreveal uses it!
  8518. buff_filename:        rs.b    32
  8519. buff_setname:        rs.b    setnamelen
  8520. buff_settings:        rs.b    settings_len
  8521. buff_fkeys:        rs.b    fkeys_lines_size
  8522. buff_len:        rs.b    0
  8523.  
  8524.     section Icons,data_c
  8525.  
  8526. AppIconData1:
  8527. ;Plane 0
  8528.     dc.w    $0000,$0000,$0000,$0400,$0000,$0000,$0000,$0C00
  8529.     dc.w    $0000,$0000,$0000,$0C00,$007F,$FFFF,$FFF0,$0C00
  8530.     dc.w    $006A,$AFFE,$AAB0,$0C00,$0040,$0198,$0010,$0C00
  8531.     dc.w    $0040,$07FF,$8010,$0C00,$0040,$7801,$F810,$0C00
  8532.     dc.w    $0441,$8000,$7E11,$0C00,$0E46,$0001,$8791,$0C00
  8533.     dc.w    $1F46,$0006,$0791,$0C00,$0458,$0018,$01E7,$CC00
  8534.     dc.w    $0458,$0060,$01E3,$8C00,$0458,$0000,$01E1,$0C00
  8535.     dc.w    $0046,$0000,$0790,$0C00,$0046,$0000,$0790,$0C00
  8536.     dc.w    $0041,$8000,$1E10,$0C00,$006A,$F801,$FAB0,$0C00
  8537.     dc.w    $007F,$FFFF,$FFF0,$0C00,$0000,$0000,$0000,$0C00
  8538.     dc.w    $0000,$0000,$0000,$0C00,$7FFF,$FFFF,$FFFF,$FC00
  8539. ;Plane 1
  8540.     dc.w    $FFFF,$FFFF,$FFFF,$F800,$D555,$5555,$5555,$5000
  8541.     dc.w    $D555,$5555,$5555,$5000,$D500,$0000,$0005,$5000
  8542.     dc.w    $D515,$5001,$5545,$5000,$D53F,$FE67,$FFE5,$5000
  8543.     dc.w    $D53F,$F800,$7FE5,$5000,$D53F,$87FE,$07E5,$5000
  8544.     dc.w    $D13E,$7FFF,$E1E4,$5000,$D139,$FFFF,$F864,$5000
  8545.     dc.w    $C039,$FFFF,$F864,$5000,$D127,$FFFF,$FE00,$1000
  8546.     dc.w    $D127,$FF9F,$FE04,$5000,$D127,$FFFF,$FE04,$5000
  8547.     dc.w    $D539,$FFFF,$F865,$5000,$D539,$FFFF,$F865,$5000
  8548.     dc.w    $D53E,$7FFF,$E165,$5000,$D515,$07FE,$0545,$5000
  8549.     dc.w    $D500,$0000,$0005,$5000,$D555,$5555,$5555,$5000
  8550.     dc.w    $D555,$5555,$5555,$5000,$8000,$0000,$0000,$0000
  8551.  
  8552. AppIcon1:
  8553.     dc.w    0,0
  8554.     dc.w    54,22,2
  8555.     dc.l    AppIconData1
  8556.     dc.b    3,0
  8557.     dc.l    NULL
  8558.  
  8559. AppIconData2:
  8560. ;Plane 0
  8561.     dc.w    $FFFF,$FFFF,$FFFF,$F800,$C000,$0000,$0000,$0000
  8562.     dc.w    $C000,$0000,$0000,$0000,$C07F,$FFFF,$FFF0,$0000
  8563.     dc.w    $C06A,$AFFE,$AAB0,$0000,$C040,$0018,$0010,$0000
  8564.     dc.w    $C45D,$D5DF,$8011,$0000,$CE49,$1481,$F011,$0000
  8565.     dc.w    $DF49,$8880,$0091,$0000,$C449,$1480,$1897,$C000
  8566.     dc.w    $C449,$D480,$9493,$8000,$CE40,$001D,$5431,$0000
  8567.     dc.w    $DF58,$0191,$D4B1,$0000,$C458,$0159,$5877,$C000
  8568.     dc.w    $C446,$0191,$4793,$8000,$C446,$015C,$0791,$0000
  8569.     dc.w    $C041,$8140,$1E10,$0000,$C06A,$F801,$FAB0,$0000
  8570.     dc.w    $C07F,$FFFF,$FFF0,$0000,$C000,$0000,$0000,$0000
  8571.     dc.w    $C000,$0000,$0000,$0000,$8000,$0000,$0000,$0000
  8572. ;Plane 1
  8573.     dc.w    $0000,$0000,$0000,$0400,$2AAA,$AAAA,$AAAA,$AC00
  8574.     dc.w    $2AAA,$AAAA,$AAAA,$AC00,$2A80,$0000,$000A,$AC00
  8575.     dc.w    $2A95,$5001,$554A,$AC00,$2ABF,$FFE7,$FFEA,$AC00
  8576.     dc.w    $2AA2,$2A20,$7FEA,$AC00,$20B6,$EB7E,$0FEA,$AC00
  8577.     dc.w    $20B6,$777F,$FF6A,$AC00,$2AB6,$EB7F,$E768,$2C00
  8578.     dc.w    $2AB6,$2B7F,$6B68,$2C00,$20BF,$FFE2,$ABCA,$AC00
  8579.     dc.w    $20A7,$FE6E,$2B4A,$AC00,$2AA7,$FEA6,$A788,$2C00
  8580.     dc.w    $2AB9,$FE6E,$B868,$2C00,$2AB9,$FEA3,$F86A,$AC00
  8581.     dc.w    $2ABE,$7EBF,$E1EA,$AC00,$2A95,$07FE,$054A,$AC00
  8582.     dc.w    $2A80,$0000,$000A,$AC00,$2AAA,$AAAA,$AAAA,$AC00
  8583.     dc.w    $2AAA,$AAAA,$AAAA,$AC00,$7FFF,$FFFF,$FFFF,$FC00
  8584.  
  8585. AppIcon2:
  8586.     dc.w    0,0
  8587.     dc.w    54,22,2
  8588.     dc.l    AppIconData2
  8589.     dc.b    3,0
  8590.     dc.l    NULL
  8591.  
  8592. AppIconDO:
  8593.     dc.w    NULL            ; Magic Number
  8594.     dc.w    NULL            ; Version
  8595.                     ; Embedded Gadget Structure
  8596.     dc.l    NULL            ; Next Gadget Pointer
  8597.     dc.w    0,0,54,23        ; Left,Top,Width,Height
  8598.     dc.w    GFLG_GADGHIMAGE        ; Flags
  8599.     dc.w    NULL            ; Activation Flags
  8600.     dc.w    NULL            ; Gadget Type
  8601.     dc.l    AppIcon1        ; Render Image
  8602.     dc.l    AppIcon2        ; Select Image
  8603.     dc.l    NULL            ; Gadget Text
  8604.     dc.l    NULL            ; Mutual Exclude
  8605.     dc.l    NULL            ; Special Info
  8606.     dc.w    NULL            ; Gadget ID
  8607.     dc.l    NULL            ; User Data
  8608.  
  8609.     dc.b    NULL,0    ;WBTOOL t.ex.      Icon Type
  8610.     dc.l    NULL            ; Default Tool
  8611.     dc.l    NULL            ; Tool Type Array
  8612.     dc.l    NO_ICON_POSITION    ; Current X
  8613.     dc.l    NO_ICON_POSITION    ; Current Y
  8614.     dc.l    NULL            ; Drawer Structure
  8615.     dc.l    NULL            ; Tool Window
  8616.     dc.l    NULL            ; Stack size
  8617.  
  8618. Textread_prefsI1Data:
  8619. ;Plane 0
  8620.     dc.w    $0000,$0000,$0004,$0000,$0000,$0000,$0001,$0000
  8621.     dc.w    $0000,$07FF,$8000,$4000,$1DD5,$D800,$6000,$1000
  8622.     dc.w    $0914,$A0FC,$1000,$0800,$0988,$C102,$0800,$0C00
  8623.     dc.w    $0914,$C082,$0800,$0C00,$09D4,$C082,$0800,$0C00
  8624.     dc.w    $0000,$2104,$0800,$0C00,$19C9,$9E18,$1000,$0C00
  8625.     dc.w    $1515,$4060,$2000,$0C00,$199D,$4080,$C000,$0C00
  8626.     dc.w    $1515,$4103,$0000,$0C00,$15D5,$821C,$0000,$0C00
  8627.     dc.w    $0000,$0109,$99DD,$CC00,$0000,$00F1,$5511,$0C00
  8628.     dc.w    $0000,$0109,$9999,$CC00,$0000,$0109,$1510,$4C00
  8629.     dc.w    $4000,$00F1,$15D1,$CC00,$1000,$0000,$0000,$0C00
  8630.     dc.w    $0400,$0000,$0000,$0C00,$01FF,$FFFF,$FFFF,$FC00
  8631. ;Plane 1
  8632.     dc.w    $FFFF,$FFFF,$FFF8,$0000,$D555,$5555,$5556,$0000
  8633.     dc.w    $D555,$5000,$5555,$8000,$C000,$07FF,$9555,$6000
  8634.     dc.w    $C000,$1F03,$E555,$5000,$C000,$3E55,$F555,$5000
  8635.     dc.w    $C000,$3F55,$F555,$5000,$C000,$3F55,$F555,$5000
  8636.     dc.w    $D555,$5E53,$F555,$5000,$C000,$0147,$E555,$5000
  8637.     dc.w    $C000,$151F,$D555,$5000,$C000,$157F,$1555,$5000
  8638.     dc.w    $C000,$14FC,$5555,$5000,$C000,$15E1,$5555,$5000
  8639.     dc.w    $D555,$54F4,$0000,$1000,$D555,$5504,$0000,$1000
  8640.     dc.w    $D555,$54F4,$0000,$1000,$D555,$54F4,$0000,$1000
  8641.     dc.w    $3555,$5504,$0000,$1000,$0D55,$5555,$5555,$5000
  8642.     dc.w    $0355,$5555,$5555,$5000,$0000,$0000,$0000,$0000
  8643.  
  8644. Textread_prefsI1:
  8645.     dc.w    0,0
  8646.     dc.w    54,22,2
  8647.     dc.l    Textread_prefsI1Data
  8648.     dc.b    3,0
  8649.     dc.l    NULL
  8650.  
  8651. Textread_prefsTools:
  8652.     dc.l    .text
  8653.     dc.l    NULL
  8654. .text
  8655.     dc.b    "FILETYPE=PREFS",0
  8656.     even
  8657.  
  8658. Textread_prefs:
  8659.     dc.w    WB_DISKMAGIC
  8660.     dc.w    WB_DISKVERSION
  8661.  
  8662.     dc.l    NULL
  8663.     dc.w    0,0,54,23
  8664.     dc.w    GFLG_GADGIMAGE!GADGBACKFILL
  8665.     dc.w    GACT_RELVERIFY!GADGIMMEDIATE
  8666.     dc.w    BOOLGADGET
  8667.     dc.l    Textread_prefsI1
  8668.     dc.l    NULL
  8669.     dc.l    NULL
  8670.     dc.l    NULL
  8671.     dc.l    NULL
  8672.     dc.w    0
  8673.     dc.l    NULL
  8674.  
  8675.      dc.b    WBPROJECT,0
  8676.     dc.l    .deftool
  8677.     dc.l    Textread_prefsTools
  8678.     dc.l    NO_ICON_POSITION
  8679.     dc.l    NO_ICON_POSITION
  8680.     dc.l    NULL
  8681.     dc.l    NULL
  8682.     dc.l    4096
  8683. .deftool
  8684.     dc.b    "Textread",0
  8685.     even
  8686.  
  8687.     section    bssdata,BSS
  8688.  
  8689. fib        ds.b    fib_SIZEOF    ;fileinfoblock, lw-aligned (splitfilepath:)
  8690. com_array:    ds.b    coma_SIZE
  8691. int:        ds.b    IS_SIZE
  8692. lockwinreq:    ds.b    rq_SIZEOF    ;(lockwindow)
  8693. XPKerrbuf:    ds.b    XPKERRMSGSIZE
  8694. colortable:    ds.l    1+(2^maxdepth)*3+1        ;(changepalette)
  8695. searchstring:    ds.b    80
  8696. screentitle:    ds.b    90
  8697. savedfont:    ds.b    ta_SIZEOF
  8698. savedfontname:    ds.b    31
  8699. numdec_buffert    ds.b    11
  8700.  
  8701. defpalette:    ds.l    (2^maxdepth)*3
  8702. setname:    ds.b    setnamelen
  8703. tabbar:        ds.b    256
  8704. printtabbar:    ds.b    256
  8705. argprojectname:    ds.b    256
  8706. temp:        ds.b    512
  8707. tempend:
  8708. tempsize    =*-temp
  8709.  
  8710. oldfontname:    ds.b    32
  8711.  
  8712. font:        ds.b    256*8
  8713.  
  8714.  
  8715. deffont:    ds.b    ta_SIZEOF
  8716. deffontname:    ds.b    31
  8717. prefs_id_test:    ds.b    prefs_id_len+1
  8718.  
  8719.     section windows,code
  8720.  
  8721.  
  8722.  
  8723. HRWv    MACRO        ;character,function
  8724.     dc.w    \1
  8725.     dc.l    \2
  8726.     ENDM
  8727.  
  8728. HRWr    MACRO        ;keycode,qual (or),function
  8729.     dc.w    \1,\2
  8730.     dc.l    \3
  8731.     ENDM
  8732.  
  8733. HRWg    MACRO
  8734.     dc.w    \1
  8735.     dc.l    \2
  8736.     ENDM
  8737.  
  8738. HWRv_SIZEOF    EQU    2+4
  8739. HWRr_SIZEOF    EQU    2+2+4
  8740. HWRg_SIZEOF    EQU    2+4
  8741.  
  8742.     RSRESET
  8743. hrw_window    rs.l    1
  8744. hrw_render    rs.l    1
  8745. hrw_vkeys    rs.l    1
  8746. hrw_rkeys    rs.l    1
  8747. hrw_gadgets    rs.l    1
  8748.  
  8749.  
  8750.  
  8751.  
  8752.  
  8753. ;ut:
  8754. * d0    -1    avsluta Textread
  8755. * d0    0    allt ok, leta inte
  8756. * d0    1    allt ok, leta
  8757. requestsearch:
  8758.  
  8759.     move.l    screenptr,a1
  8760.     bsr    OpenfindreqWindow
  8761.     tst.l    d0
  8762.     bne.w    .error
  8763.     jsr    lockwindow
  8764.  
  8765.     move.w    search_wild,.wild+2
  8766.     move.w    search_case,.casesens+2
  8767.     move.w    search_dir,.dir+2
  8768.  
  8769.     BASE    gt
  8770.     move.l    findreq(pc),a4
  8771.     suba.l    a2,a2
  8772.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8773.     move.l    a4,a1
  8774.     lea    .searchfor_tags(pc),a3
  8775.     call    GT_SetGadgetAttrsA
  8776.     move.l    findreqGadgets+GD_sw_casesens*4(pc),a0
  8777.     move.l    a4,a1
  8778.     lea    .casesens_tags(pc),a3
  8779.     call    GT_SetGadgetAttrsA
  8780.     move.l    findreqGadgets+GD_sw_wildcards*4(pc),a0
  8781.     move.l    a4,a1
  8782.     lea    .wildcards_tags(pc),a3
  8783.     call    GT_SetGadgetAttrsA
  8784.     move.l    findreqGadgets+GD_sw_fwdbwd*4(pc),a0
  8785.     move.l    a4,a1
  8786.     lea    .direction_tags(pc),a3
  8787.     call    GT_SetGadgetAttrsA
  8788.  
  8789.     BASE    intui
  8790.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8791.     move.l    findreq(pc),a1
  8792.     suba.l    a2,a2
  8793.     call    ActivateGadget
  8794.  
  8795.     lea    .strukt(pc),a0
  8796.     move.l    findreq(pc),(a0)
  8797.     bsr    handlerequestwindow
  8798.     move.l    d0,-(sp)
  8799.     jsr    unlockwindow
  8800.     bsr    ClosefindreqWindow
  8801.     move.l    (sp)+,d0
  8802.     rts
  8803. .error
  8804.     moveq    #0,d0
  8805.     rts
  8806. .strukt
  8807.     dc.l    0
  8808.     dc.l    .render
  8809.     dc.l    .strukt_v
  8810.     dc.l    .strukt_r
  8811.     dc.l    .strukt_g
  8812.  
  8813. .strukt_v
  8814.     HRWv    "s",.fn_search
  8815.     HRWv    $0d,.fn_search
  8816.     HRWv    "u",.fn_use
  8817.     HRWv    "c",.fn_cancel
  8818.     HRWv    $1b,.fn_cancel
  8819.     HRWv    "f",.fn_find
  8820.     HRWv    "w",.fn_wild
  8821.     HRWv    "a",.fn_case
  8822.     HRWv    "d",.fn_dir
  8823.     HRWv    -1,-1
  8824. .strukt_r
  8825.     HRWr    -1,-1,-1
  8826. .strukt_g
  8827.  
  8828.     HRWg    GD_sw_searchfor,.fn_findgad
  8829.     HRWg    GD_sw_wildcards,.fn_wildgad
  8830.     HRWg    GD_sw_casesens,.fn_casegad
  8831.     HRWg    GD_sw_fwdbwd,.fn_dirgad
  8832.     HRWg    GD_sw_search,.fn_searchgad
  8833.     HRWg    GD_sw_use,.fn_usegad
  8834.     HRWg    GD_sw_cancel,.fn_cancelgad
  8835.     HRWg    -1,-1
  8836.  
  8837. .render
  8838. ;    bsr    searchwindowRender
  8839.     rts
  8840.  
  8841. .fn_search
  8842.     move.l    hrw_window(a5),a2
  8843.     move.l    findreqGadgets+GD_sw_search*4(pc),a3
  8844.     jsr    PressButton
  8845. .fn_searchgad
  8846.     bsr.w    .update
  8847.     move.w    #1+1,d0
  8848.     rts
  8849. .fn_use
  8850.     move.l    hrw_window(a5),a2
  8851.     move.l    findreqGadgets+GD_sw_use*4(pc),a3
  8852.     jsr    PressButton
  8853. .fn_usegad
  8854.     bsr.w    .update
  8855.     move.w    #0+1,d0
  8856.     rts
  8857. .fn_cancel
  8858.     move.l    hrw_window(a5),a2
  8859.     move.l    findreqGadgets+GD_sw_cancel*4(pc),a3
  8860.     jsr    PressButton
  8861. .fn_cancelgad
  8862.     move.w    #0+1,d0
  8863.     rts
  8864. .fn_find
  8865.     BASE    intui
  8866.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8867.     move.l    findreq(pc),a1
  8868.     suba.l    a2,a2
  8869.     call    ActivateGadget
  8870.     moveq    #0,d0
  8871.     rts
  8872. .fn_findgad
  8873.     and.w    #IEQUALIFIERB_LSHIFT!IEQUALIFIERB_RSHIFT,d4
  8874.     beq.w    .fn_search
  8875.     moveq    #0,d0
  8876.     rts
  8877. .fn_wild
  8878.     bchg    #0,.wild+3
  8879.     move.l    findreqGadgets+GD_sw_wildcards*4(pc),a0
  8880.     move.l    findreq(pc),a1
  8881.     suba.l    a2,a2
  8882.     lea    .wildcards_tags(pc),a3
  8883.     call    GT_SetGadgetAttrsA
  8884.     moveq    #0,d0
  8885.     rts
  8886. .fn_wildgad
  8887.     clr.l    .wild
  8888.     move.w    gg_Flags(a2),d0
  8889.     and.w    #GFLG_SELECTED,d0
  8890.     beq.s    .fn_wildgad_notselected
  8891.     addq.l    #1,.wild
  8892. .fn_wildgad_notselected
  8893.     moveq    #0,d0
  8894.     rts
  8895. .fn_case
  8896.     bchg    #0,.casesens+3
  8897.     move.l    findreqGadgets+GD_sw_casesens*4(pc),a0
  8898.     move.l    findreq(pc),a1
  8899.     suba.l    a2,a2
  8900.     lea    .casesens_tags(pc),a3
  8901.     call    GT_SetGadgetAttrsA
  8902.     moveq    #0,d0
  8903.     rts
  8904. .fn_casegad
  8905.     clr.l    .casesens
  8906.     move.w    gg_Flags(a2),d0
  8907.     and.w    #GFLG_SELECTED,d0
  8908.     beq.s    .fn_casegad_notselected
  8909.     addq.l    #1,.casesens
  8910. .fn_casegad_notselected
  8911.     moveq    #0,d0
  8912.     rts
  8913. .fn_dir
  8914.     bchg    #0,.dir+3
  8915.     move.l    findreqGadgets+GD_sw_fwdbwd*4(pc),a0
  8916.     move.l    findreq(pc),a1
  8917.     suba.l    a2,a2
  8918.     lea    .direction_tags(pc),a3
  8919.     call    GT_SetGadgetAttrsA
  8920.     moveq    #0,d0
  8921.     rts
  8922. .fn_dirgad
  8923.     move.l    d3,.dir
  8924.     moveq    #0,d0
  8925.     rts
  8926.  
  8927. .update
  8928.     move.w    .wild+2,search_wild
  8929.     move.w    .casesens+2,search_case
  8930.     move.w    .dir+2,search_dir
  8931.     move.l    findreqGadgets+GD_sw_searchfor*4(pc),a0
  8932.     move.l    gg_SpecialInfo(a0),a0
  8933.     move.l    si_Buffer(a0),a0
  8934.     moveq    #79,d0
  8935.     lea    searchstring,a1
  8936. .fn_use_copy
  8937.     move.b    (a0)+,(a1)+
  8938.     dbeq    d0,.fn_use_copy
  8939.     rts
  8940.     
  8941. .searchfor_tags
  8942.     dc.l    GTST_String,searchstring
  8943.     dc.l    TAG_DONE
  8944. .casesens_tags
  8945.     dc.l    GTCB_Checked
  8946. .casesens
  8947.     dc.l    0            ;1=japps
  8948.     dc.l    TAG_DONE
  8949. .wildcards_tags
  8950.     dc.l    GTCB_Checked
  8951. .wild
  8952.     dc.l    0            ;1=wildcards on
  8953.     dc.l    TAG_DONE
  8954. .direction_tags
  8955.     dc.l    GTCY_Active
  8956. .dir
  8957.     dc.l    0            ;1=backwards
  8958.     dc.l    TAG_DONE
  8959.  
  8960. ;ut:
  8961. * d0    -1    avsluta Textread
  8962. * d0    0    allt ok, byt inte
  8963. * d0    1    allt ok, byt
  8964. requesttabsize:
  8965.     move.l    screenptr,a1
  8966.     bsr    OpentabsizereqWindow
  8967.     tst.l    d0
  8968.     bne.b    .error
  8969.     jsr    lockwindow
  8970.  
  8971.     move.l    tabsize,.level
  8972.     bsr    .uppdateraslidern
  8973.  
  8974.  
  8975.     lea    .strukt(pc),a0
  8976.     move.l    tabsizereq(pc),(a0)
  8977.     bsr    handlerequestwindow
  8978.     move.l    d0,-(sp)
  8979.     jsr    unlockwindow
  8980.     bsr    ClosetabsizereqWindow
  8981.     move.l    (sp)+,d0
  8982.     rts
  8983. .error
  8984.     moveq    #0,d0
  8985.     rts
  8986.  
  8987. .strukt
  8988.     dc.l    0
  8989.     dc.l    .render
  8990.     dc.l    .strukt_v
  8991.     dc.l    .strukt_r
  8992.     dc.l    .strukt_g
  8993.  
  8994. .strukt_v
  8995.     HRWv    "u",.fn_use
  8996.     HRWv    $0d,.fn_use
  8997.     HRWv    "c",.fn_cancel
  8998.     HRWv    $1b,.fn_cancel
  8999.     HRWv    "t",.fn_inc
  9000.     HRWv    "T",.fn_dec
  9001.     HRWv    -1,-1
  9002. .strukt_r
  9003.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4f,.fn_first
  9004.     HRWr    0,$4f,.fn_dec
  9005.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4e,.fn_last
  9006.     HRWr    0,$4e,.fn_inc
  9007.     HRWr    0,$4c,.fn_center
  9008.     HRWr    -1,-1,-1
  9009. .strukt_g
  9010.     HRWg    GD_tw_use,.fn_usegad
  9011.     HRWg    GD_tw_cancel,.fn_cancelgad
  9012.     HRWg    GD_tw_tabsize,.fn_slider
  9013.     HRWg    -1,-1
  9014.  
  9015. .render
  9016. ;    bsr    tabsizereqRender
  9017.     rts
  9018.  
  9019. .fn_use
  9020.     move.l    hrw_window(a5),a2
  9021.     move.l    tabsizereqGadgets+GD_tw_use*4(pc),a3
  9022.     jsr    PressButton
  9023. .fn_usegad
  9024.     move.l    .level,tabsize
  9025.     moveq    #1+1,d0
  9026.     rts
  9027. .fn_cancel
  9028.     move.l    hrw_window(a5),a2
  9029.     move.l    tabsizereqGadgets+GD_tw_cancel*4(pc),a3
  9030.     jsr    PressButton
  9031. .fn_cancelgad
  9032.     moveq    #0+1,d0
  9033.     rts
  9034. .fn_dec
  9035.     cmp.l    #1,.level
  9036.     beq.b    .fn_dec_first
  9037.     subq.l    #1,.level
  9038. .fn_dec_first
  9039.     bra.b    .uppdateraslidern
  9040. .fn_inc
  9041.     cmp.l    #15,.level
  9042.     beq.b    .fn_inc_last
  9043.     addq.l    #1,.level
  9044. .fn_inc_last
  9045.     bra.b    .uppdateraslidern
  9046. .fn_first
  9047.     move.l    #1,.level
  9048.     bra.b    .uppdateraslidern
  9049. .fn_last
  9050.     move.l    #15,.level
  9051.     bra.b    .uppdateraslidern
  9052. .fn_center
  9053.     move.l    #8,.level
  9054.     bra.w    .uppdateraslidern
  9055. .fn_slider
  9056.     move.l    d3,.level
  9057.     moveq    #0,d0
  9058.     rts
  9059. .uppdateraslidern
  9060.     BASE    gt
  9061.     move.l    tabsizereqGadgets+GD_tw_tabsize*4(pc),a0
  9062.     move.l    tabsizereq(pc),a1
  9063.     suba.l    a2,a2
  9064.     lea    .upp_tabsize_level(pc),a3
  9065.     call    GT_SetGadgetAttrsA
  9066.     moveq    #0,d0
  9067.     rts
  9068.  
  9069. .upp_tabsize_level
  9070.     dc.l    GTSL_Level
  9071. .level    dc.l    0
  9072.     dc.l    TAG_DONE
  9073.  
  9074.  
  9075. ;ut:
  9076. * d0    -1    avsluta Textread
  9077. * d0    0    allt ok, byt inte
  9078. * d0    1    allt ok, byt
  9079. requestreveal:
  9080.     lea    bufflist,a1        ;update buffer numbers ('xx: filename')
  9081.     moveq    #1,d1
  9082. .stepdown
  9083.     TSTNODE    a1,a1
  9084.     beq.b    .listok
  9085.     move.l    d1,d0
  9086.     addq.l    #1,d1
  9087.     jsr    numdec
  9088.     lea    buff_number(a1),a2
  9089.     move.b    8(a0),(a2)+
  9090.     move.b    9(a0),(a2)+
  9091.     move.b    #":",(a2)+
  9092.     move.b    #" ",(a2)+
  9093.     bra.b    .stepdown
  9094. .listok
  9095.  
  9096.     move.l    screenptr,a1
  9097.     bsr    OpenrevealreqWindow
  9098.     tst.l    d0
  9099.     bne.b    .error
  9100.     jsr    lockwindow
  9101.  
  9102.     BASE    gt
  9103.     move.l    revealreqGadgets+GD_rw_list*4(pc),a0
  9104.     move.l    revealreq(pc),a1
  9105.     suba.l    a2,a2
  9106.     lea    .initlist_tags(pc),a3
  9107.     call    GT_SetGadgetAttrsA
  9108.  
  9109.     move.l    bnum,.selected
  9110.     subq.l    #1,.selected
  9111.     bsr    .uppdateralistan
  9112.  
  9113.     lea    .strukt(pc),a0
  9114.     move.l    revealreq(pc),(a0)
  9115.     bsr    handlerequestwindow
  9116.     move.l    d0,-(sp)
  9117.     jsr    unlockwindow
  9118.     bsr    CloserevealreqWindow
  9119.     move.l    (sp)+,d0
  9120.     rts
  9121. .error
  9122.     moveq    #0,d0
  9123.     rts
  9124. .initlist_tags
  9125.     dc.l    GTLV_Labels,bufflist
  9126.     dc.l    TAG_DONE
  9127. .strukt
  9128.     dc.l    0
  9129.     dc.l    .render
  9130.     dc.l    .strukt_v
  9131.     dc.l    .strukt_r
  9132.     dc.l    .strukt_g
  9133.  
  9134. .strukt_v
  9135.     HRWv    "u",.fn_use
  9136.     HRWv    $0d,.fn_use
  9137.     HRWv    "c",.fn_cancel
  9138.     HRWv    $1b,.fn_cancel
  9139.     HRWv    "b",.fn_next
  9140.     HRWv    "B",.fn_prev
  9141.     HRWv    -1,-1
  9142. .strukt_r
  9143.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4c,.fn_top
  9144.     HRWr    0,$4c,.fn_prev
  9145.     HRWr    IEQUALIFIER_LSHIFT!IEQUALIFIER_RSHIFT,$4d,.fn_end
  9146.     HRWr    0,$4d,.fn_next
  9147.     HRWr    -1,-1,-1
  9148. .strukt_g
  9149.  
  9150.     HRWg    GD_rw_list,.fn_list
  9151.     HRWg    GD_rw_use,.fn_usegad
  9152.     HRWg    GD_rw_cancel,.fn_cancelgad
  9153.     HRWg    -1,-1
  9154.  
  9155. .render
  9156.     rts
  9157.  
  9158. .fn_use
  9159.     move.l    hrw_window(a5),a2
  9160.     move.l    revealreqGadgets+GD_rw_use*4(pc),a3
  9161.     jsr    PressButton
  9162. .fn_usegad
  9163.     move.l    .selected,bnum
  9164.     addq.l    #1,bnum
  9165.     move.w    #1+1,d0
  9166.     rts
  9167. .fn_cancel
  9168.     move.l    hrw_window(a5),a2
  9169.     move.l    revealreqGadgets+GD_rw_cancel*4(pc),a3
  9170.     jsr    PressButton
  9171. .fn_cancelgad
  9172.     move.w    #0+1,d0
  9173.     rts
  9174. .fn_next
  9175.     move.l    bmax,d0
  9176.     subq.l    #1,d0
  9177.     cmp.l    .selected,d0
  9178.     beq.b    .fn_next_last
  9179.     addq.l    #1,.selected
  9180. .fn_next_last
  9181.     bra.w    .uppdateralistan
  9182. .fn_prev
  9183.     tst.l    .selected
  9184.     beq.b    .fn_prev_first
  9185.     subq.l    #1,.selected
  9186. .fn_prev_first
  9187.     bra.w    .uppdateralistan
  9188. .fn_top
  9189.     clr.l    .selected
  9190.     bra.w    .uppdateralistan
  9191. .fn_end
  9192.     move.l    bmax,.selected
  9193.     subq.l    #1,.selected
  9194.     bra.w    .uppdateralistan
  9195. .fn_list
  9196.     move.l    .fn_list_time(pc),d0
  9197.     move.l    .fn_list_time+4(pc),d1
  9198.     move.l    d5,.fn_list_time
  9199.     move.l    d6,.fn_list_time+4
  9200.  
  9201.     move.l    .selected(pc),d4
  9202.     move.l    d3,.selected
  9203.     cmp.l    .selected(pc),d4
  9204.     bne    .fn_list_exit
  9205.     move.l    d5,d2
  9206.     move.l    d6,d3
  9207.     BASE    intui
  9208.     call    DoubleClick
  9209.     tst.l    d0
  9210.     bne.w    .fn_use
  9211. .fn_list_exit
  9212.     moveq    #0,d0
  9213.     rts
  9214. .fn_list_time
  9215.     dc.l    0,0
  9216.  
  9217. .uppdateralistan
  9218.     BASE    gt
  9219.     cmp.w    #39,LIB_VERSION(a6)
  9220.     bhs.b    .uppdateralistan_selected
  9221. *** Kludge för <V39
  9222.     move.l    .top(pc),d0
  9223.     cmp.l    .selected(pc),d0
  9224.     bmi.b    .uppdateralistan_notB4
  9225.     move.l    .selected(pc),.top
  9226.     bra.b    .uppdateralistan_doit
  9227. .uppdateralistan_notB4
  9228.     addq.l    #6-1,d0                ;?????????? WHERE?? FIXIT!
  9229.     cmp.l    .selected(pc),d0
  9230.     bpl.b    .uppdateralistan_selected
  9231.     move.l    .selected(pc),d0
  9232.     subq.l    #6-1,d0
  9233.     move.l    d0,.top
  9234. .uppdateralistan_doit
  9235.     move.l    revealreqGadgets+GD_rw_list*4(pc),a0
  9236.     move.l    revealreq(pc),a1
  9237.     suba.l    a2,a2
  9238.     lea    .top_tags(pc),a3
  9239.     call    GT_SetGadgetAttrsA
  9240. .uppdateralistan_selected
  9241.     move.l    .selected,.visible
  9242.     move.l    revealreqGadgets+GD_rw_list*4(pc),a0
  9243.     move.l    revealreq(pc),a1
  9244.     suba.l    a2,a2
  9245.     lea    .selected_tags(pc),a3
  9246.     call    GT_SetGadgetAttrsA
  9247.  
  9248.     moveq    #0,d0
  9249.     rts
  9250.  
  9251. .selected_tags
  9252.     dc.l    GTLV_Selected
  9253. .selected
  9254.     dc.l    0
  9255.     dc.l    GTLV_MakeVisible
  9256. .visible
  9257.     dc.l    0
  9258.     dc.l    TAG_DONE
  9259.  
  9260. .top_tags
  9261.     dc.l    GTLV_Top
  9262. .top
  9263.     dc.l    0
  9264.     dc.l    TAG_DONE
  9265.  
  9266. requestprintopts:
  9267.     jsr    lockwindow
  9268.     bsr    printoptions
  9269.     move.l    d0,-(sp)
  9270.     jsr    unlockwindow
  9271.     move.l    (sp)+,d0
  9272.     rts
  9273.  
  9274.  
  9275.  
  9276. ;ut:
  9277. * d0    -1    avsluta Textread
  9278. * d0    0    allt ok, byt inte rad
  9279. * d0    1    allt ok, byt rad
  9280. * d1    tal
  9281. requestpercent:
  9282. .again
  9283.     move.l    linepos,d0
  9284.     mulu.w    #100,d0
  9285.     move.l    lines,d1
  9286.     sub.l    cheight,d1
  9287.     beq.b    .nodiv
  9288.     divu.w    d1,d0
  9289. .nodiv
  9290.     and.l    #$0000ffff,d0
  9291.     lea    .number(pc),a0
  9292.     move.l    d0,(a0)
  9293.     lea    .text1(pc),a1
  9294.     lea    .text2(pc),a2
  9295.  
  9296.     bsr    requestinteger
  9297.  
  9298.     tst.l    d0
  9299.     bmi.b    .exit
  9300.     beq.b    .exit
  9301.  
  9302.     move.l    .number(pc),d1
  9303.  
  9304.     cmp.l    #100,d1
  9305.     bhi.b    .again
  9306.  
  9307. .exit
  9308.     rts
  9309.  
  9310. .text1    dc.b    "Go to %",0
  9311. .text2    dc.b    "Min: 0 -- Max: 100"
  9312. .number    dc.l    0
  9313.  
  9314. ;ut:
  9315. * d0    -1    avsluta Textread
  9316. * d0    0    allt ok, byt inte rad
  9317. * d0    1    allt ok, byt rad
  9318. * d1    tal
  9319. requestline:
  9320. .again
  9321.     move.l    lines,d0
  9322.     sub.l    cheight,d0
  9323.     bpl.b    .ok
  9324.     moveq    #0,d0
  9325. .ok
  9326.     lea    .max(pc),a0
  9327.     move.l    d0,(a0)
  9328.     jsr    numdec
  9329.     move.l    d0,a0
  9330.     lea    .text2n(pc),a1
  9331. .loop
  9332.     move.b    (a0)+,(a1)+
  9333.     bne.b    .loop
  9334.  
  9335.     lea    .linepos(pc),a0
  9336.     move.l    linepos,(a0)
  9337.     lea    .text1(pc),a1
  9338.     lea    .text2(pc),a2
  9339.  
  9340.     bsr    requestinteger
  9341.     tst.l    d0
  9342.     bmi.b    .exit
  9343.     beq.b    .exit
  9344.     move.l    .linepos(pc),d1
  9345.     cmp.l    .max(pc),d1
  9346.     bhi.b    .again
  9347. .exit
  9348.     rts
  9349. .max        dc.l    0
  9350. .linepos    dc.l    0
  9351. .text1    dc.b    "Go to line",0
  9352. .text2    dc.b    "Min: 0 -- Max: "
  9353. .text2n    dc.b    "xxxxxxxx",0
  9354.     even
  9355. ;in:
  9356. * a0    default number
  9357. * a1    text1
  9358. * a2    text2
  9359. ;ut:
  9360. * d0    -1    avsluta Textread
  9361. * d0    0    allt ok, byt inte rad
  9362. * d0    1    allt ok, byt rad
  9363. requestinteger:
  9364.     lea    .init_number(pc),a3
  9365.     move.l    (a0),(a3)
  9366.     lea    .number(pc),a3
  9367.     move.l    a0,(a3)
  9368.     lea    .init_text1(pc),a3
  9369.     move.l    a1,(a3)
  9370.     lea    .init_text2(pc),a3
  9371.     move.l    a2,(a3)
  9372.  
  9373.     move.l    screenptr,a1
  9374.     bsr    OpenintegerreqWindow
  9375.     tst.l    d0
  9376.     bne.b    .error
  9377.     jsr    lockwindow
  9378.  
  9379.     BASE    gt
  9380.     move.l    integerreqGadgets+GD_iw_integer*4(pc),a0
  9381.     move.l    integerreq(pc),a1
  9382.     suba.l    a2,a2
  9383.     lea    .init_number_tags(pc),a3
  9384.     call    GT_SetGadgetAttrsA
  9385.  
  9386.     move.l    integerreqGadgets+GD_iw_text1*4(pc),a0
  9387.     move.l    integerreq(pc),a1
  9388.     suba.l    a2,a2
  9389.     lea    .init_text1_tags(pc),a3
  9390.     call    GT_SetGadgetAttrsA
  9391.  
  9392.     move.l    integerreqGadgets+GD_iw_text2*4(pc),a0
  9393.     move.l    integerreq(pc),a1
  9394.     suba.l    a2,a2
  9395.     lea    .init_text2_tags(pc),a3
  9396.     call    GT_SetGadgetAttrsA
  9397.  
  9398.     BASE    intui
  9399.     move.l    integerreqGadgets+GD_iw_integer*4(pc),a0
  9400.     move.l    integerreq(pc),a1
  9401.     suba.l    a2,a2
  9402.     call    ActivateGadget
  9403.  
  9404.     lea    .strukt(pc),a0
  9405.     move.l    integerreq(pc),(a0)
  9406.     bsr    handlerequestwindow
  9407.     move.l    d0,-(sp)
  9408.     jsr    unlockwindow
  9409.     bsr    CloseintegerreqWindow
  9410.     move.l    (sp)+,d0
  9411.     rts
  9412. .error
  9413.     moveq    #0,d0
  9414.     rts
  9415. .number
  9416.     dc.l    0
  9417. .strukt
  9418.     dc.l    0
  9419.     dc.l    .render
  9420.     dc.l    .strukt_v
  9421.     dc.l    .strukt_r
  9422.     dc.l    .strukt_g
  9423.  
  9424. .strukt_v
  9425.     HRWv    "u",.fn_use
  9426.     HRWv    $0d,.fn_use
  9427.     HRWv    "c",.fn_cancel
  9428.     HRWv    $1b,.fn_cancel
  9429.     HRWv    -1,-1
  9430. .strukt_r
  9431.     HRWr    -1,-1,-1
  9432. .strukt_g
  9433.     HRWg    GD_iw_use,.fn_usegad
  9434.     HRWg    GD_iw_cancel,.fn_cancelgad
  9435.     HRWg    GD_iw_integer,.fn_integer
  9436.     HRWg    -1,-1
  9437.  
  9438. .render
  9439. ;    bsr    integerreqRender
  9440.     rts
  9441.  
  9442. .fn_use
  9443.     move.l    hrw_window(a5),a2
  9444.     move.l    integerreqGadgets+GD_iw_use*4(pc),a3
  9445.     jsr    PressButton
  9446. .fn_usegad
  9447.     move.l    .number(pc),a1
  9448.     move.l    integerreqGadgets+GD_iw_integer*4(pc),a0
  9449.     move.l    gg_SpecialInfo(a0),a0
  9450.     move.l    si_LongInt(a0),(a1)
  9451.     moveq    #1+1,d0
  9452.     rts
  9453. .fn_cancel
  9454.     move.l    hrw_window(a5),a2
  9455.     move.l    integerreqGadgets+GD_iw_cancel*4(pc),a3
  9456.     jsr    PressButton
  9457. .fn_cancelgad
  9458.     moveq    #0+1,d0
  9459.     rts
  9460. .fn_integer
  9461.     and.w    #IEQUALIFIERB_LSHIFT!IEQUALIFIERB_RSHIFT,d4
  9462.     beq.w    .fn_use
  9463.     moveq    #0,d0
  9464.     rts
  9465.  
  9466. .init_number_tags
  9467.     dc.l    GTIN_Number
  9468. .init_number
  9469.     dc.l    0
  9470.     dc.l    TAG_DONE
  9471.  
  9472. .init_text1_tags
  9473.     dc.l    GTTX_Text
  9474. .init_text1
  9475.     dc.l    0
  9476.     dc.l    TAG_DONE
  9477.  
  9478. .init_text2_tags
  9479.     dc.l    GTTX_Text
  9480. .init_text2
  9481.     dc.l    0
  9482.     dc.l    TAG_DONE
  9483.  
  9484. ;in:
  9485. * a0    struktur
  9486. handlerequestwindow
  9487.     move.l    a0,a5
  9488. .handlerequesterwindow_loop
  9489.  
  9490.     clr.w    .status
  9491.     base    exec
  9492.     move.l    hrw_window(a5),a0
  9493.     move.l    wd_UserPort(a0),a0
  9494.     move.b    MP_SIGBIT(a0),d1
  9495.     moveq    #0,d0
  9496.     bset    d1,d0
  9497.     lea    .usersignal(pc),a0
  9498.     move.l    d0,(a0)
  9499.  
  9500.     bset    #SIGBREAKB_CTRL_C,d0
  9501.  
  9502.     call    Wait
  9503.     lea    .signal(pc),a0
  9504.     move.l    d0,(a0)
  9505.     move.l    d0,d1
  9506.     and.l    .usersignal(pc),d1    ;signalerade userport?
  9507.     beq.W    .nouserport
  9508.                     ;joo..
  9509. .handleIDCMP
  9510.     BASE    gt
  9511.     move.l    hrw_window(a5),a0
  9512.     move.l    wd_UserPort(a0),a0    ;userport
  9513.     call    GT_GetIMsg
  9514.     tst.l    d0
  9515.     beq.w    .nomoremsgs
  9516.     move.l    d0,a0
  9517.  
  9518.     move.l    im_Class(a0),d2
  9519.  
  9520.     move.l    im_IAddress(a0),a2
  9521.     moveq    #0,d3
  9522.     move.w    im_Code(a0),d3
  9523.     move.w    im_Qualifier(a0),d4
  9524.     move.l    im_Seconds(a0),d5
  9525.     move.l    im_Micros(a0),d6
  9526.  
  9527.     move.l    a0,a1
  9528.     call    GT_ReplyIMsg
  9529.  
  9530.     cmp.l    #IDCMP_VANILLAKEY,d2
  9531.     bne.w    .dontcheckVkeys
  9532.     move.l    hrw_vkeys(a5),a0
  9533. .Vkeys_loop
  9534.     move.w    (a0),d0
  9535.     cmp.w    #-1,d0
  9536.     beq.b    .handleIDCMP
  9537.     cmp.w    d3,d0
  9538.     bne.b    .Vkeys_nope
  9539.     move.l    2(a0),a0
  9540.     jsr    (a0)
  9541.     bra.w    .fn_return
  9542. .Vkeys_nope
  9543.     add.w    #HWRv_SIZEOF,a0
  9544.     bra.b    .Vkeys_loop
  9545.  
  9546. .dontcheckVkeys
  9547.     cmp.l    #IDCMP_RAWKEY,d2
  9548.     bne.w    .dontcheckRkeys
  9549.  
  9550.     move.l    hrw_rkeys(a5),a0
  9551. .Rkeys_loop
  9552.     move.w    (a0),d0
  9553.     beq.b    .Rkeys_testcode
  9554.     cmp.w    #-1,d0
  9555.     beq.b    .handleIDCMP
  9556.     and.w    d4,d0
  9557.     beq.b    .Rkeys_nope
  9558. .Rkeys_testcode
  9559.     cmp.w    2(a0),d3
  9560.     bne.b    .Rkeys_nope
  9561.     move.l    4(a0),a0
  9562.     jsr    (a0)
  9563.     bra.b    .fn_return
  9564. .Rkeys_nope
  9565.     add.w    #HWRr_SIZEOF,a0
  9566.     bra.b    .Rkeys_loop
  9567.  
  9568. .dontcheckRkeys
  9569.     cmp.l    #IDCMP_GADGETUP,d2
  9570.     bne.w    .dontpressgadgets
  9571.     move.w    gg_GadgetID(a2),d1
  9572.  
  9573.     move.l    hrw_gadgets(a5),a0
  9574. .gad_loop
  9575.     move.w    (a0),d0
  9576.     cmp.w    #-1,d0
  9577.     beq.w    .handleIDCMP
  9578.     cmp.w    d1,d0
  9579.     bne.b    .gad_nope
  9580.     move.l    2(a0),a0
  9581.     jsr    (a0)
  9582.     bra.b    .fn_return
  9583. .gad_nope
  9584.     add.w    #HWRg_SIZEOF,a0
  9585.     bra.b    .gad_loop
  9586.  
  9587. .dontpressgadgets
  9588.     cmp.l    #IDCMP_REFRESHWINDOW,d2
  9589.     bne.s    .dontrefreshwindow
  9590.     BASE    gt
  9591.     move.l    hrw_window(a5),a0
  9592.     call    GT_BeginRefresh
  9593.  
  9594.     move.l    hrw_render(a5),a0
  9595.     jsr    (a0)
  9596.  
  9597.     BASE    gt
  9598.     move.l    hrw_window(a5),a0
  9599.     moveq    #TRUE,d0
  9600.     call    GT_EndRefresh
  9601. .dontrefreshwindow
  9602.     bra.w    .handleIDCMP
  9603. .fn_return
  9604.     move.w    d0,.status
  9605. .nomoremsgs
  9606.     tst.w    .status
  9607.     bne.s    .exit
  9608.  
  9609. .nouserport
  9610.     move.l    .signal(pc),d1
  9611.     and.l    #SIGBREAKF_CTRL_C,d1
  9612.     beq.B    .nobreak
  9613.     lea    status,a0
  9614.     bset    #s_exit,(a0)        ;om ctrl_c från cli, sluta direkt!
  9615.     moveq    #err_exitnow,d0
  9616.     rts
  9617. .nobreak
  9618.     bra.w    .handlerequesterwindow_loop
  9619. .exit
  9620.     moveq    #0,d0
  9621.     move.w    .status(pc),d0
  9622.     subq.l    #1,d0
  9623.     rts
  9624. .signal        dc.l    0
  9625. .usersignal    dc.l    0
  9626. .status        dc.w    0
  9627.  
  9628.  
  9629.  
  9630.  
  9631.  
  9632. printfile:
  9633.     tst.l    filelen
  9634.     beq.w    .exit
  9635.  
  9636.     BASE    intui
  9637.     move.l    windowptr,a0
  9638.     move.l    #-1,a1
  9639.     lea    .printing(pc),a2
  9640.     call    SetWindowTitles
  9641.  
  9642.     BASE    exec
  9643.     call    CreateMsgPort
  9644.     lea    .port(pc),a0
  9645.     move.l    d0,(a0)
  9646.     beq.w    .error
  9647.     move.l    d0,a0
  9648. ;    ifgt    IOSTD_SIZE,iopcr_SIZEOF
  9649.     moveq    #IOSTD_SIZE,d0
  9650. ;    else
  9651. ;    moveq    #iopcr_SIZEOF,d0
  9652. ;    endif
  9653.     call    CreateIORequest        ;union IOStdReq och IOPrtCmdReq
  9654.     lea    mpio(pc),a0
  9655.     move.l    d0,(a0)
  9656.     beq.w    .error
  9657.     move.l    d0,a1
  9658.     move.l    unit,d0            ;skrivarenhet
  9659.     lea    .printer(pc),a0
  9660.     moveq    #0,d1
  9661.     call    OpenDevice
  9662.     lea    .deverr(pc),a0
  9663.     move.l    d0,(a0)
  9664.     bne.w    .error
  9665.  
  9666. ;    call    Forbid            ;ingen multitasking nu
  9667.     lea    tabsize,a0
  9668.     move.l    (a0),-(sp)
  9669.     move.l    mptab,(a0)
  9670.     lea    printtabbar,a0
  9671.     jsr    fixatabbar
  9672.     lea    tabsize,a0
  9673.     move.l    (sp)+,(a0)
  9674. ;    base    exec
  9675. ;    call    Permit
  9676.  
  9677.     move.l    mpio(pc),a0
  9678.     move.l    IO_DEVICE(a0),a0
  9679.     lea    pd_Preferences(a0),a0
  9680.     move.w    pf_PrintLeftMargin(a0),d0
  9681. ;    subq.w    #1,d0
  9682.     move.w    pf_PrintRightMargin(a0),d1
  9683.     sub.w    d0,d1
  9684.     lea    .prwidth(pc),a1
  9685.     move.w    d1,(a1)
  9686.     beq.w    .error            ;inga tecken/rad alls?!
  9687.     move.w    pf_PaperLength(a0),d0
  9688.     lea    .prheight(pc),a1
  9689.     move.w    d0,(a1)
  9690.     lea    mppage,a0
  9691.     clr.w    (a0)
  9692.  
  9693.     base    exec
  9694.     move.l    mpio(pc),a1
  9695.     lea    temp,a0
  9696.     move.l    a0,IO_DATA(a1)
  9697.     move.w    #PRD_QUERY,IO_COMMAND(a1)
  9698.     call    DoIO
  9699.     tst.l    d0
  9700.     bne.w    .error
  9701.     move.l    mpio(pc),a1
  9702.     cmp.l    #1,IO_ACTUAL(a1)
  9703.     bne.b    .notpar
  9704.     move.b    temp,d0
  9705.     btst    #0,d0
  9706.     bne.w    .offline    ;offline
  9707.     btst    #1,d0
  9708.     bne.w    .nopaper    ;paper out
  9709. .notpar
  9710.     lea    .prheight(pc),a1
  9711.     move.b    mpinfo,d0
  9712.     beq.b    .ingetuppe
  9713.     subq.w    #2,(a1)
  9714. .ingetuppe
  9715.     move.w    #aRIN,d0
  9716.     bsr.w    mprintcommand
  9717.     bne.w    .error
  9718.     move.l    fileaddr,a2
  9719.     move.l    filelen,a3
  9720.     add.l    a2,a3
  9721. .nextpage
  9722.     lea    mppage,a0
  9723.     addq.w    #1,(a0)
  9724.  
  9725.     move.l    a2,a4
  9726.     move.l    a3,a5
  9727.     move.b    mpinfo,d0
  9728.     beq.b    .tileprinted
  9729.     lea    mpheader,a2
  9730.     move.b    (a2)+,d0
  9731.     bsr.w    mprintstyle
  9732.     tst.l    d0
  9733.     bne.w    .error
  9734.  
  9735.     bsr.w    mpgettitfoot
  9736.     BASE    exec
  9737.     move.l    mpio(pc),a1
  9738.     move.l    #-1,IO_LENGTH(a1)
  9739.     move.l    a0,IO_DATA(a1)
  9740.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9741.     call    DoIO
  9742.     tst.l    d0
  9743.     bne.w    .error
  9744.     move.w    #aNEL,d0
  9745.     bsr.w    mprintcommand
  9746.     bne.w    .error
  9747.     move.w    #aNEL,d0
  9748.     bsr.w    mprintcommand
  9749.     bne.w    .error
  9750. .tileprinted
  9751.     move.w    #aSGR0,d0
  9752.     bsr.w    mprintcommand
  9753.     bne.w    .error
  9754.     move.l    a4,a2
  9755.     move.l    a5,a3
  9756.     move.w    .prheight(pc),d7
  9757. .nextline
  9758.     suba.l    a1,a1            ;tala om att början på rad!
  9759.  
  9760.     lea    temp,a0
  9761.     move.w    .prwidth(pc),d1
  9762.     moveq    #0,d2
  9763. .nextchar
  9764.     moveq    #0,d0
  9765.     move.b    (a2)+,d0
  9766.     move.b    d0,(a0)+
  9767.     cmp.l    a2,a3
  9768.     beq.w    .textslut
  9769.     cmp.b    #LF,d0
  9770.     beq.b    .printline
  9771.     cmp.b    #12,d0
  9772.     bne.b    .not12
  9773.     moveq    #0,d7            ;sid-slut
  9774.     bra.b    .printline
  9775. .not12
  9776.     cmp.b    #" ",d0
  9777.     bne.b    .notSPACE
  9778.     move.l    a0,a1
  9779.     move.l    a2,a5
  9780. .notSPACE
  9781.     cmp.b    #TAB,d0
  9782.     bne.b    .notTAB
  9783.     move.l    a0,a1
  9784.     move.l    a2,a5
  9785.     lea    printtabbar,a4
  9786.     moveq    #0,d0
  9787.     move.b    (a4,d2.w),d0
  9788.     sub.w    d2,d0
  9789.     move.b    (a4,d2.w),d2
  9790.     subq.w    #1,d0
  9791.     subq.l    #1,a0            ;bort med tab!
  9792. .fillspace
  9793.     move.b    #" ",(a0)+
  9794.     dbf    d0,.fillspace
  9795.     bra.b    .charfinished
  9796. .notTAB
  9797.     cmp.b    #" ",d0
  9798.     blo.b    .nonascii
  9799.     cmp.b    #$80,d0
  9800.     blo.b    .ascii
  9801.     cmp.b    #$a0,d0
  9802.     bhs.b    .ascii
  9803. .nonascii
  9804.     move.b    #".",-1(a0)
  9805. .ascii
  9806.     addq.w    #1,d2
  9807. .charfinished
  9808.     cmp.w    d1,d2
  9809.     blo.B    .nextchar
  9810.     sub.w    d1,d2            ;om man har gått över gränsen(=tab)
  9811.     sub.w    d2,a0            ;klipp av !
  9812.     move.b    mpww,d0
  9813.     beq.b    .noww
  9814.     move.l    a1,d0
  9815.     beq.b    .noww
  9816.     move.l    a1,a0
  9817.     subq.l    #1,a0            ;ta bort spacet oxå!
  9818.     move.l    a5,a2
  9819. .noww
  9820.     move.b    #10,(a0)+
  9821. .printline
  9822.     clr.b    (a0)
  9823.     move.l    mpio(pc),a1
  9824.     move.l    #-1,IO_LENGTH(a1)
  9825.     lea    temp,a0
  9826.     move.l    a0,IO_DATA(a1)
  9827.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9828.     call    DoIO
  9829.     tst.l    d0
  9830.     bne.B    .error
  9831.     dbf    d7,.nextline        ;<-
  9832.     bra.w    .nextpage
  9833. .textslut
  9834.     clr.b    (a0)
  9835.     move.l    mpio(pc),a1
  9836.     move.l    #-1,IO_LENGTH(a1)
  9837.     lea    temp,a0
  9838.     move.l    a0,IO_DATA(a1)
  9839.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9840.     call    DoIO
  9841.     move.l    mpio(pc),a1
  9842.     move.l    #-1,IO_LENGTH(a1)
  9843.     lea    .cls,a0
  9844.     move.l    a0,IO_DATA(a1)
  9845.     move.w    #CMD_WRITE,IO_COMMAND(a1)
  9846.     call    DoIO
  9847.     move.l    mpio(pc),a1
  9848.     move.w    #CMD_FLUSH,IO_COMMAND(a1)
  9849.     call    DoIO
  9850.     move.l    mpio(pc),a1
  9851.     call    AbortIO
  9852.     move.l    mpio(pc),a1
  9853.     call    WaitIO
  9854. .error
  9855.     BASE    exec
  9856.     move.l    mpio(pc),d0
  9857.     beq.B    .noio
  9858.     move.l    .deverr(pc),d0
  9859.     bne.b    .wasdeverr
  9860.     move.l    mpio(pc),a1
  9861.     call    CloseDevice
  9862.     lea    .deverr(pc),a0
  9863.     clr.l    (a0)
  9864. .wasdeverr
  9865.     move.l    mpio(pc),a0
  9866.     call    DeleteIORequest
  9867.     lea    mpio(pc),a0
  9868.     clr.l    (a0)
  9869. .noio
  9870.     move.l    .port(pc),d0
  9871.     beq.B    .noport
  9872.     move.l    d0,a0
  9873.     call    DeleteMsgPort
  9874.     lea    .port(pc),a0
  9875.     clr.l    (a0)
  9876. .noport
  9877.     BASE    intui
  9878.     move.l    windowptr,a0
  9879.     move.l    #-1,a1
  9880.     lea    screentitle,a2
  9881.     call    SetWindowTitles
  9882. .exit
  9883.     moveq    #0,d0
  9884.     rts
  9885. .offline
  9886.     bsr.b    .error
  9887.     lea    .offlinemessage(pc),a1
  9888.     lea    oktext,a2
  9889.     suba.l    a4,a4
  9890.     jsr    requester
  9891.     moveq    #0,d0
  9892.     rts
  9893. .nopaper
  9894.     bsr.b    .error
  9895.     lea    .nopapermessage(pc),a1
  9896.     lea    oktext,a2
  9897.     suba.l    a4,a4
  9898.     jsr    requester
  9899.     moveq    #0,d0
  9900.     rts
  9901. .offlinemessage
  9902.     dc.b    "Printer is not on-line.",0
  9903. .nopapermessage
  9904.     dc.b    "Printer is out of paper.",0
  9905.     even
  9906.  
  9907. .prwidth    dc.w    0
  9908. .prheight    dc.w    0
  9909. .port        dc.l    0
  9910. .deverr        dc.l    0
  9911. .printer    dc.b    "printer.device",0
  9912. .printing    dc.b    "Printing file...",0
  9913. .cls        dc.b    12,0
  9914.     even
  9915. mpio:        dc.l    0
  9916.  
  9917. mprintstyle:
  9918.     move.w    d0,d2
  9919.     move.w    #aSGR0,d0
  9920.     bsr.B    mprintcommand
  9921.     bne.B    .error
  9922.     btst    #0,d2
  9923.     beq.B    .nobold
  9924.     move.w    #aSGR1,d0        ;fet
  9925.     bsr.B    mprintcommand
  9926.     bne.B    .error
  9927. .nobold
  9928.     btst    #1,d2
  9929.     beq.B    .noital
  9930.     move.w    #aSGR3,d0        ;kursiv
  9931.     bsr.B    mprintcommand
  9932.     bne.B    .error
  9933. .noital
  9934.     btst    #2,d2
  9935.     beq.B    .nounder
  9936.     move.w    #aSGR4,d0        ;understryk
  9937.     bsr.B    mprintcommand
  9938.     bne.B    .error
  9939. .nounder
  9940.     moveq    #0,d0
  9941. .error
  9942.     rts
  9943. ;in:
  9944. * d0    kommando
  9945. ;ut:
  9946. * Z-flaggan 0 om fel (d0<>0)
  9947. mprintcommand:
  9948.     BASE    exec
  9949.     move.l    mpio(pc),a1
  9950.     move.w    d0,io_PrtCommand(a1)
  9951.     clr.l    io_Parm0(a1)        ;0-3
  9952.     move.w    #PRD_PRTCOMMAND,IO_COMMAND(a1)
  9953.     call    DoIO
  9954.     tst.l    d0
  9955.     rts
  9956. ;in:
  9957. * a2    pek till tre bytar
  9958. ;ut:
  9959. * a0    sträng att skriva ut,0
  9960. mpgettitfoot:
  9961.     lea    temp+256,a0
  9962.     moveq    #79,d0
  9963. .fill
  9964.     move.b    #" ",(a0)+
  9965.     dbf    d0,.fill
  9966.     clr.b    (a0)
  9967.  
  9968.     move.b    (a2)+,d0
  9969.     bsr.B    .retright
  9970.     tst.l    d0
  9971.     beq.b    .next1
  9972.     lea    temp+256,a1
  9973. .copy1
  9974.     move.b    (a0)+,(a1)+
  9975.     bne.b    .copy1
  9976.     move.b    #" ",-(a1)
  9977. .next1
  9978.     move.b    (a2)+,d0
  9979.     bsr.B    .retright
  9980.     tst.l    d0
  9981.     beq.b    .next2
  9982.     lsr.l    #1,d0
  9983.     lea    temp+256+40,a1
  9984.     sub.l    d0,a1
  9985. .copy2
  9986.     move.b    (a0)+,(a1)+
  9987.     bne.b    .copy2
  9988.     move.b    #" ",-(a1)
  9989. .next2
  9990.     move.b    (a2)+,d0
  9991.     bsr.B    .retright
  9992.     lea    temp+256+80,a1
  9993.     tst.l    d0
  9994.     beq.b    .next3
  9995.     sub.l    d0,a1
  9996. .copy3
  9997.     move.b    (a0)+,(a1)+
  9998.     bne.b    .copy3
  9999. .next3
  10000.     lea    temp+256,a0
  10001.     rts
  10002. .retright
  10003.     cmp.b    #1,d0
  10004.     bne.B    .notfilename
  10005.     lea    filename,a0
  10006.     moveq    #30,d0            ;längd
  10007.     rts
  10008. .notfilename
  10009.     cmp.b    #2,d0
  10010.     bne.B    .nottitle
  10011.     lea    mptitle,a0
  10012.     moveq    #30,d0            ;längd
  10013.     rts
  10014. .nottitle
  10015.     cmp.b    #3,d0
  10016.     bne.B    .notdate
  10017.     lea    .datetime(pc),a0
  10018.     move.b    #FORMAT_INT,dat_Format(a0)
  10019.     lea    temp,a1
  10020.     move.l    a1,dat_StrDate(a0)
  10021.     BASE    dos
  10022.     move.l    a0,d1
  10023.     call    DateStamp
  10024.     move.l    d0,d1
  10025.     call    DateToStr
  10026.     tst.l    d0
  10027.     beq.b    .rrexit
  10028.     moveq    #-1,d0
  10029.     lea    temp,a0
  10030. .findnull
  10031.     addq.l    #1,d0
  10032.     tst.b    (a0)+
  10033.     bne.b    .findnull
  10034.     lea    temp,a0
  10035.     rts
  10036. .notdate
  10037.     cmp.b    #4,d0
  10038.     bne.B    .notsidnum
  10039.     moveq    #0,d0
  10040.     move.w    mppage,d0
  10041.     jsr    numdec
  10042.     lea    temp,a1
  10043.     move.l    d0,a0
  10044.     moveq    #3,d0
  10045.     move.b    #"-",(a1)+
  10046.     move.b    #" ",(a1)+
  10047. .copyside
  10048.     addq.w    #1,d0
  10049.     move.b    (a0)+,(a1)+
  10050.     bne.b    .copyside
  10051.     move.b    #" ",-1(a1)
  10052.     move.b    #"-",(a1)+
  10053.     clr.b    (a1)
  10054.     lea    temp,a0
  10055.     rts
  10056. .notsidnum
  10057. .rrexit
  10058.     moveq    #0,d0
  10059.     rts    
  10060. .datetime
  10061.     blk.b    dat_SIZEOF
  10062. printoptions:
  10063.     lea    pol,a0
  10064.     lea    .l2(pc),a1
  10065.     move.l    (a0)+,(a1)+
  10066.     move.l    (a0)+,(a1)+
  10067.     move.l    (a0)+,(a1)+
  10068.     move.l    (a0)+,(a1)+
  10069.     move.l    (a0)+,(a1)+
  10070.     move.l    (a0)+,(a1)+
  10071.     move.l    (a0)+,(a1)+
  10072.  
  10073.     lea    .leftactive(pc),a0
  10074.     move.l    pol,(a0)
  10075.     lea    .midactive(pc),a0
  10076.     move.l    pom,(a0)
  10077.     lea    .rightactive(pc),a0
  10078.     move.l    por,(a0)
  10079.     lea    .wwon(pc),a0
  10080.     move.l    pow,(a0)
  10081.     lea    .tabsize(pc),a0
  10082.     move.l    mptab,(a0)
  10083.     lea    .boldon(pc),a0
  10084.     move.l    pob,(a0)
  10085.     lea    .italon(pc),a0
  10086.     move.l    poi,(a0)
  10087.     lea    .underon(pc),a0
  10088.     move.l    pou,(a0)
  10089.  
  10090.     move.l    cwidthp,d0
  10091.     sub.l    #428,d0
  10092.     lsr.l    #1,d0
  10093.     lea    .pwinx(pc),a0
  10094.     move.l    d0,(a0)
  10095.     move.l    pheight,d0
  10096.     sub.l    #142,d0
  10097.     lsr.l    #1,d0
  10098.     lea    .pwiny(pc),a0
  10099.     move.l    d0,(a0)
  10100.  
  10101.     BASE    intui
  10102.     lea    .pwindowonscreen(pc),a0
  10103.     move.l    screenptr,(a0)
  10104.     suba.l    a0,a0
  10105.     lea    .pwindowtags(pc),a1
  10106.     call    OpenWindowTagList
  10107.     lea    .pwindowptr(pc),a0
  10108.     move.l    d0,(a0)
  10109.     beq.w    .error
  10110.  
  10111.     BASE    gt
  10112.     lea    .pgadgetptr(pc),a0
  10113.     call    CreateContext
  10114.     move.l    d0,d7
  10115.  
  10116.     lea    .pnewgadget(pc),a3
  10117.     move.w    #20,gng_LeftEdge(a3)
  10118.     move.w    #30,gng_TopEdge(a3)
  10119.     clr.w    gng_Width(a3)
  10120.     clr.w    gng_Height(a3)
  10121.     clr.l    gng_GadgetText(a3)
  10122.     lea    topaz8font,a0
  10123.     move.l    a0,gng_TextAttr(a3)
  10124.     move.l    #PLACETEXT_RIGHT,gng_Flags(a3)
  10125.     move.l    screenvi,gng_VisualInfo(a3)
  10126.     clr.w    gng_GadgetID(a3)        ;start noll
  10127.     clr.l    gng_UserData(a3)
  10128.  
  10129.     move.l    d7,a0
  10130.     move.l    a3,a1
  10131.     lea    .lefttags(pc),a2
  10132.     move.l    #MX_KIND,d0
  10133.     call    CreateGadgetA
  10134.     lea    .leftgadget(pc),a0
  10135.     move.l    d0,(a0)
  10136.     beq.w    .error
  10137.     move.l    d0,d7
  10138.  
  10139.     addq.w    #1,gng_GadgetID(a3)
  10140.     add.w    #150,gng_LeftEdge(a3)
  10141.  
  10142.     move.l    d7,a0
  10143.     move.l    a3,a1
  10144.     lea    .midtags(pc),a2
  10145.     move.l    #MX_KIND,d0
  10146.     call    CreateGadgetA
  10147.     lea    .midgadget(pc),a0
  10148.     move.l    d0,(a0)
  10149.     beq.w    .error
  10150.     move.l    d0,d7
  10151.  
  10152.     addq.w    #1,gng_GadgetID(a3)
  10153.     add.w    #150,gng_LeftEdge(a3)
  10154.  
  10155.     move.l    d7,a0
  10156.     move.l    a3,a1
  10157.     lea    .righttags(pc),a2
  10158.     move.l    #MX_KIND,d0
  10159.     call    CreateGadgetA
  10160.     lea    .rightgadget(pc),a0
  10161.     move.l    d0,(a0)
  10162.     beq.w    .error
  10163.     move.l    d0,d7
  10164.  
  10165.     addq.w    #1,gng_GadgetID(a3)
  10166.     move.w    #105,gng_TopEdge(a3)
  10167.     move.w    #170,gng_LeftEdge(a3)
  10168.     lea    .ww(pc),a0
  10169.     move.l    a0,gng_GadgetText(a3)
  10170.  
  10171.     move.l    d7,a0
  10172.     move.l    a3,a1
  10173.     lea    .wwtags(pc),a2
  10174.     move.l    #CHECKBOX_KIND,d0
  10175.     call    CreateGadgetA
  10176.     lea    .wwgadget(pc),a0
  10177.     move.l    d0,(a0)
  10178.     beq.w    .error
  10179.     move.l    d0,d7
  10180.  
  10181.     addq.w    #1,gng_GadgetID(a3)
  10182.     move.w    #125,gng_TopEdge(a3)
  10183.     move.w    #20,gng_LeftEdge(a3)
  10184.     move.w    #12,gng_Height(a3)
  10185.     move.w    #60,gng_Width(a3)
  10186.     move.l    #PLACETEXT_IN,gng_Flags(a3)
  10187.     lea    .print(pc),a0
  10188.     move.l    a0,gng_GadgetText(a3)
  10189.     
  10190.     move.l    d7,a0
  10191.     move.l    a3,a1
  10192.     lea    tag_done,a2
  10193.     move.l    #BUTTON_KIND,d0
  10194.     call    CreateGadgetA
  10195.     lea    .printgadget(pc),a0
  10196.     move.l    d0,(a0)
  10197.     beq.w    .error
  10198.     move.l    d0,d7
  10199.  
  10200.     addq.w    #1,gng_GadgetID(a3)
  10201.     move.w    #185,gng_LeftEdge(a3)
  10202.     lea    .use(pc),a0
  10203.     move.l    a0,gng_GadgetText(a3)
  10204.     
  10205.     move.l    d7,a0
  10206.     move.l    a3,a1
  10207.     lea    tag_done,a2
  10208.     move.l    #BUTTON_KIND,d0
  10209.     call    CreateGadgetA
  10210.     lea    .usegadget(pc),a0
  10211.     move.l    d0,(a0)
  10212.     beq.w    .error
  10213.     move.l    d0,d7
  10214.  
  10215.     addq.w    #1,gng_GadgetID(a3)
  10216.     move.w    #348,gng_LeftEdge(a3)
  10217.     lea    .cancel(pc),a0
  10218.     move.l    a0,gng_GadgetText(a3)
  10219.     
  10220.     move.l    d7,a0
  10221.     move.l    a3,a1
  10222.     lea    tag_done,a2
  10223.     move.l    #BUTTON_KIND,d0
  10224.     call    CreateGadgetA
  10225.     lea    .cancelgadget(pc),a0
  10226.     move.l    d0,(a0)
  10227.     beq.w    .error
  10228.     move.l    d0,d7
  10229.  
  10230.     addq.w    #1,gng_GadgetID(a3)
  10231.     move.w    #90,gng_TopEdge(a3)
  10232.     move.w    #68,gng_LeftEdge(a3)
  10233.     move.w    #261,gng_Width(a3)
  10234.     move.l    #PLACETEXT_LEFT,gng_Flags(a3)
  10235.     lea    .title(pc),a0
  10236.     move.l    a0,gng_GadgetText(a3)
  10237.  
  10238.     move.l    d7,a0
  10239.     move.l    a3,a1
  10240.     lea    .titletags(pc),a2
  10241.     move.l    #STRING_KIND,d0
  10242.     call    CreateGadgetA
  10243.     lea    .titlegadget(pc),a0
  10244.     move.l    d0,(a0)
  10245.     beq.w    .error
  10246.     move.l    d0,d7
  10247.  
  10248.     addq.w    #1,gng_GadgetID(a3)
  10249.     move.w    #105,gng_TopEdge(a3)
  10250.     move.w    #92,gng_LeftEdge(a3)
  10251.     move.w    #37,gng_Width(a3)
  10252.     lea    .tab(pc),a0
  10253.     move.l    a0,gng_GadgetText(a3)
  10254.  
  10255.     move.l    d7,a0
  10256.     move.l    a3,a1
  10257.     lea    .tabtags(pc),a2
  10258.     move.l    #INTEGER_KIND,d0
  10259.     call    CreateGadgetA
  10260.     lea    .tabgadget(pc),a0
  10261.     move.l    d0,(a0)
  10262.     beq.w    .error
  10263.     move.l    d0,d7
  10264.  
  10265.     move.w    #75,gng_TopEdge(a3)
  10266.     addq.w    #1,gng_GadgetID(a3)
  10267.     move.w    #20,gng_LeftEdge(a3)
  10268.     move.l    #PLACETEXT_RIGHT,gng_Flags(a3)
  10269.     lea    .bold(pc),a0
  10270.     move.l    a0,gng_GadgetText(a3)
  10271.  
  10272.     move.l    d7,a0
  10273.     move.l    a3,a1
  10274.     lea    .boldtags(pc),a2
  10275.     move.l    #CHECKBOX_KIND,d0
  10276.     call    CreateGadgetA
  10277.     lea    .boldgadget(pc),a0
  10278.     move.l    d0,(a0)
  10279.     beq.w    .error
  10280.     move.l    d0,d7
  10281.  
  10282.     addq.w    #1,gng_GadgetID(a3)
  10283.     add.w    #150,gng_LeftEdge(a3)
  10284.     lea    .under(pc),a0
  10285.     move.l    a0,gng_GadgetText(a3)
  10286.  
  10287.     move.l    d7,a0
  10288.     move.l    a3,a1
  10289.     lea    .undertags(pc),a2
  10290.     move.l    #CHECKBOX_KIND,d0
  10291.     call    CreateGadgetA
  10292.     lea    .undergadget(pc),a0
  10293.     move.l    d0,(a0)
  10294.     beq.w    .error
  10295.     move.l    d0,d7
  10296.  
  10297.     addq.w    #1,gng_GadgetID(a3)
  10298.     add.w    #150,gng_LeftEdge(a3)
  10299.     lea    .ital(pc),a0
  10300.     move.l    a0,gng_GadgetText(a3)
  10301.  
  10302.     move.l    d7,a0
  10303.     move.l    a3,a1
  10304.     lea    .italtags(pc),a2
  10305.     move.l    #CHECKBOX_KIND,d0
  10306.     call    CreateGadgetA
  10307.     lea    .italgadget(pc),a0
  10308.     move.l    d0,(a0)
  10309.     beq.w    .error
  10310.     move.l    d0,d7
  10311.  
  10312.     lea.l    filelen,a0
  10313.     tst.l    (a0)
  10314.     bne.b    .textinmem
  10315.     move.l    .printgadget(pc),a0
  10316.     or.w    #GFLG_DISABLED,gg_Flags(a0)
  10317. .textinmem
  10318.  
  10319.     move.l    .titlegadget(pc),a0
  10320.     move.l    .pwindowptr(pc),a1
  10321.     suba.l    a2,a2
  10322.     BASE    intui
  10323.     cmp.l    #2,pol
  10324.     beq.s    .aa
  10325.     call    OffGadget
  10326.     bra.S    .ba
  10327. .aa
  10328.     call    OnGadget
  10329. .ba
  10330.  
  10331.     BASE    intui
  10332.     move.l    .pwindowptr(pc),a0
  10333.     move.l    wd_RPort(a0),a0
  10334.     moveq    #0,d0
  10335.     moveq    #0,d1
  10336.     lea    .windowtext(pc),a1
  10337.     call    PrintIText
  10338.  
  10339.     move.l    .pwindowptr(pc),a0
  10340.     move.l    .pgadgetptr(pc),a1
  10341.     suba.l    a2,a2
  10342.     moveq    #0,d0
  10343.     moveq    #-1,d1
  10344.     call    AddGList
  10345.  
  10346.     move.l    .pwindowptr(pc),a1
  10347.     move.l    .pgadgetptr(pc),a0
  10348.     suba.l    a2,a2
  10349.     moveq    #-1,d0
  10350.     call    RefreshGList
  10351.     BASE    gt
  10352.     move.l    .pwindowptr(pc),a0
  10353.     suba.l    a1,a1
  10354.     call    GT_RefreshWindow
  10355. .wait
  10356.     BASE    exec
  10357.     move.l    .pwindowptr(pc),a0
  10358.     move.l    wd_UserPort(a0),a0
  10359.     call    WaitPort
  10360. .nextmsg
  10361.     BASE    gt
  10362.     move.l    .pwindowptr(pc),a0
  10363.     move.l    wd_UserPort(a0),a0
  10364.     call    GT_GetIMsg
  10365.     tst.l    d0
  10366.     beq.b    .wait
  10367.  
  10368.     moveq    #0,d3
  10369.     moveq    #0,d4
  10370.     move.l    d0,a0
  10371.     move.l    im_IAddress(a0),a2
  10372.     move.l    im_Class(a0),d2
  10373.     move.w    im_Code(a0),d3
  10374.     move.w    im_Qualifier(a0),d4
  10375.     move.l    d0,a1
  10376.     call    GT_ReplyIMsg
  10377.     cmp.l    #IDCMP_GADGETUP,d2
  10378.     bne.w    .notup
  10379.     cmp.w    #3,gg_GadgetID(a2)
  10380.     bne.b    .not3
  10381.     lea    pow+3,a0
  10382.     bchg    #0,(a0)            ;TRUE/FALSE
  10383. .not3
  10384.     cmp.w    #4,gg_GadgetID(a2)
  10385.     bne.b    .not4
  10386.     bsr.w    .error            ;stäng fönster
  10387.     bsr.w    .fixset
  10388.     moveq    #1,d0
  10389.     rts
  10390. .not4
  10391.     cmp.w    #5,gg_GadgetID(a2)
  10392.     bne.b    .not5
  10393.     bsr.w    .error            ;stäng fönster
  10394.     bra.w    .fixset
  10395. .not5
  10396.     cmp.w    #6,gg_GadgetID(a2)
  10397.     bne.b    .not6
  10398.     bsr.w    .error            ;stäng fönster
  10399.     bra.w    .resset
  10400. .not6
  10401.     cmp.w    #9,gg_GadgetID(a2)
  10402.     bne.b    .not9
  10403.     lea    pob+3,a0
  10404.     bchg    #0,(a0)            ;TRUE/FALSE
  10405. .not9
  10406.     cmp.w    #10,gg_GadgetID(a2)
  10407.     bne.b    .not10
  10408.     lea    pou+3,a0
  10409.     bchg    #0,(a0)            ;TRUE/FALSE
  10410. .not10
  10411.     cmp.w    #11,gg_GadgetID(a2)
  10412.     bne.b    .not11
  10413.     lea    poi+3,a0
  10414.     bchg    #0,(a0)            ;TRUE/FALSE
  10415. .not11
  10416.     bra.w    .nextmsg
  10417. .notup
  10418.     cmp.l    #IDCMP_GADGETDOWN,d2
  10419.     bne.b    .notdown
  10420.     tst.w    gg_GadgetID(a2)
  10421.     bne.b    .not0
  10422.     lea    pol,a0
  10423.     move.l    d3,(a0)
  10424.  
  10425.     move.l    .titlegadget(pc),a0
  10426.     move.l    .pwindowptr(pc),a1
  10427.     suba.l    a2,a2
  10428.     BASE    intui
  10429.     cmp.l    #2,d3
  10430.     beq.s    .a
  10431.     call    OffGadget
  10432.     bra.S    .b
  10433. .a
  10434.     call    OnGadget
  10435. .b
  10436.     bra.w    .nextmsg
  10437. .not0
  10438.     cmp.w    #1,gg_GadgetID(a2)
  10439.     bne.b    .not1
  10440.     lea    pom,a0
  10441.     move.l    d3,(a0)
  10442.     bra.w    .nextmsg
  10443. .not1
  10444.     cmp.w    #2,gg_GadgetID(a2)
  10445.     bne.b    .not2
  10446.     lea    por,a0
  10447.     move.l    d3,(a0)
  10448. .not2
  10449.     bra.w    .nextmsg
  10450. .notdown
  10451.     cmp.l    #IDCMP_REFRESHWINDOW,d2
  10452.     bne.w    .nextmsg
  10453.     BASE    gt
  10454.     move.l    .pwindowptr(pc),a0
  10455.     call    GT_BeginRefresh
  10456.     move.l    .pwindowptr(pc),a0
  10457.     moveq    #TRUE,d0
  10458.     call    GT_EndRefresh
  10459.     bra.w    .nextmsg
  10460. .error
  10461.     BASE    exec
  10462.     call    Forbid
  10463.     BASE    gt
  10464. .nextmsg1
  10465. .nextmsg2
  10466.     move.l    .pwindowptr(pc),a0
  10467.     move.l    wd_UserPort(a0),a0
  10468.     call    GT_GetIMsg
  10469.     tst.l    d0
  10470.     beq.b    .nullmsg2
  10471.     move.l    d0,a1
  10472.     call    GT_ReplyIMsg
  10473.     bra.b    .nextmsg2
  10474. .nullmsg2
  10475.     BASE    exec
  10476.     call    Permit
  10477.  
  10478.     BASE    intui
  10479.     move.l    .pwindowptr(pc),d0
  10480.     beq.b    .nowindow
  10481.     move.l    d0,a0
  10482.     call    CloseWindow
  10483. .nowindow
  10484.     lea    .pwindowptr(pc),a0
  10485.     clr.l    (a0)
  10486.  
  10487.     BASE    gt
  10488.     lea    .pgadgetptr(pc),a2
  10489.     move.l    (a2),a0
  10490.     call    FreeGadgets
  10491.     clr.l    (a2)
  10492.  
  10493.     moveq    #0,d0
  10494.     rts
  10495. .fixset
  10496.     moveq    #0,d0
  10497.     lea    mpheader+1,a0
  10498.     move.b    pol+3,(a0)+
  10499.     beq.b    .olle1
  10500.     addq    #1,d0
  10501. .olle1
  10502.     move.b    pom+3,(a0)+
  10503.     beq.b    .olle2
  10504.     addq.b    #2,-1(a0)
  10505.     addq    #1,d0
  10506. .olle2
  10507.     move.b    por+3,(a0)+
  10508.     beq.b    .olle3
  10509.     addq.b    #2,-1(a0)
  10510.     addq    #1,d0
  10511. .olle3
  10512.     lea    mpinfo,a0
  10513.     move.b    #1,(a0)
  10514.     tst.w    d0
  10515.     bne.b    .olle4
  10516.     clr.b    (a0)
  10517. .olle4
  10518.     lea    mpww,a0
  10519.     move.b    pow+3,(a0)
  10520.     lea    pob,a0
  10521.     move.l    (a0)+,d1
  10522.     move.l    (a0)+,d0
  10523.     lsl.w    #1,d0
  10524.     or.w    d0,d1
  10525.     move.l    (a0)+,d0
  10526.     lsl.w    #2,d0
  10527.     or.w    d0,d1
  10528.     lea    mpheader,a0
  10529.     move.b    d1,(a0)
  10530.     move.l    .titlegadget(pc),a0
  10531.     move.l    gg_SpecialInfo(a0),a0
  10532.     move.l    si_Buffer(a0),a0
  10533.     lea    mptitle,a1
  10534.     moveq    #29+1,d0        ;nollan oxå!
  10535. .copytitle
  10536.     move.b    (a0)+,(a1)+
  10537.     dbeq    d0,.copytitle
  10538.     move.l    .tabgadget(pc),a0
  10539.     move.l    gg_SpecialInfo(a0),a0
  10540.     move.l    si_LongInt(a0),d0
  10541.     lea    mptab,a0
  10542.     cmp.l    #16,d0
  10543.     bls.b    .tsok
  10544.     moveq    #16,d0
  10545. .tsok
  10546.     move.l    d0,(a0)
  10547.     moveq    #0,d0
  10548.     rts
  10549. .resset
  10550.     lea    .l2(pc),a0
  10551.     lea    pol,a1
  10552.     move.l    (a0)+,(a1)+
  10553.     move.l    (a0)+,(a1)+
  10554.     move.l    (a0)+,(a1)+
  10555.     move.l    (a0)+,(a1)+
  10556.     move.l    (a0)+,(a1)+
  10557.     move.l    (a0)+,(a1)+
  10558.     move.l    (a0)+,(a1)+
  10559.     moveq    #0,d0
  10560.     rts
  10561. .pnewgadget    blk.b    gng_SIZEOF,0
  10562. .pwindowptr    dc.l    0
  10563. .pwindowtags
  10564.     dc.l    WA_Left
  10565. .pwinx    dc.l    50
  10566.     dc.l    WA_Top
  10567. .pwiny    dc.l    25
  10568.     dc.l    WA_Width,428
  10569.     dc.l    WA_Height,142
  10570.     dc.l    WA_CustomScreen
  10571. .pwindowonscreen
  10572.     dc.l    0
  10573.     dc.l    WA_SmartRefresh,TRUE
  10574.     dc.l    WA_Activate,TRUE
  10575.     dc.l    WA_IDCMP,IDCMP_REFRESHWINDOW!MXIDCMP!BUTTONIDCMP!CHECKBOXIDCMP!INTEGERIDCMP!STRINGIDCMP
  10576.     dc.l    TAG_DONE
  10577.  
  10578. .lefttags
  10579.     dc.l    GTMX_Labels,.leftlabels
  10580.     dc.l    GTMX_Spacing,2
  10581.     dc.l    GTMX_Active
  10582. .leftactive
  10583.     dc.l    0
  10584.     dc.l    TAG_DONE
  10585. .leftlabels
  10586.     dc.l    .none
  10587.     dc.l    .filename
  10588.     dc.l    .title
  10589.     dc.l    0
  10590. .midtags
  10591.     dc.l    GTMX_Labels,.midlabels
  10592.     dc.l    GTMX_Spacing,2
  10593.     dc.l    GTMX_Active
  10594. .midactive
  10595.     dc.l    0
  10596.     dc.l    TAG_DONE
  10597. .midlabels
  10598.     dc.l    .none
  10599.     dc.l    .date
  10600.     dc.l    .pagenum
  10601.     dc.l    0
  10602. .righttags
  10603.     dc.l    GTMX_Labels,.rightlabels
  10604.     dc.l    GTMX_Spacing,2
  10605.     dc.l    GTMX_Active
  10606. .rightactive
  10607.     dc.l    0
  10608.     dc.l    TAG_DONE
  10609. .rightlabels
  10610.     dc.l    .none
  10611.     dc.l    .date
  10612.     dc.l    .pagenum
  10613.     dc.l    0
  10614. .wwtags
  10615.     dc.l    GTCB_Checked
  10616. .wwon
  10617.     dc.l    0
  10618.     dc.l    TAG_DONE
  10619. .titletags
  10620.     dc.l    GTST_String,mptitle
  10621.     dc.l    GTST_MaxChars,30
  10622.     dc.l    GA_TabCycle,FALSE
  10623.     dc.l    TAG_DONE
  10624. .tabtags
  10625.     dc.l    GTIN_Number
  10626. .tabsize
  10627.     dc.l    8
  10628.     dc.l    GTIN_MaxChars,2
  10629.     dc.l    GA_TabCycle,TRUE
  10630.     dc.l    TAG_DONE
  10631.  
  10632. .boldtags
  10633.     dc.l    GTCB_Checked
  10634. .boldon
  10635.     dc.l    0
  10636.     dc.l    TAG_DONE
  10637. .italtags
  10638.     dc.l    GTCB_Checked
  10639. .italon
  10640.     dc.l    0
  10641.     dc.l    TAG_DONE
  10642. .undertags
  10643.     dc.l    GTCB_Checked
  10644. .underon
  10645.     dc.l    0
  10646.     dc.l    TAG_DONE
  10647.  
  10648. .pgadgetptr    dc.l    0
  10649. .leftgadget    dc.l    0
  10650. .midgadget    dc.l    0
  10651. .rightgadget    dc.l    0
  10652. .wwgadget    dc.l    0
  10653. .printgadget    dc.l    0
  10654. .usegadget    dc.l    0
  10655. .cancelgadget    dc.l    0
  10656. .titlegadget    dc.l    0
  10657. .tabgadget    dc.l    0
  10658. .boldgadget    dc.l    0
  10659. .italgadget    dc.l    0
  10660. .undergadget    dc.l    0
  10661.  
  10662. .none    dc.b    "Nothing",0
  10663. .filename dc.b    "Filename",0
  10664. .title    dc.b    "Title",0
  10665. .date    dc.b    "Date",0
  10666. .pagenum dc.b    "Page #",0
  10667. .ww    dc.b    "Wrap words",0
  10668. .print    dc.b    "Print",0
  10669. .use    dc.b    "Use",0
  10670. .cancel    dc.b    "Cancel",0
  10671. .tab    dc.b    "Tab size",0
  10672. .bold    dc.b    "Bold",0
  10673. .ital    dc.b    "Italic",0
  10674. .under    dc.b    "Underlined",0
  10675.     even
  10676.  
  10677. .l2    dc.l    0
  10678. .m2    dc.l    0
  10679. .r2    dc.l    0
  10680. .w2    dc.l    0
  10681. .b2    dc.l    TRUE
  10682. .i2    dc.l    FALSE
  10683. .u2    dc.l    TRUE
  10684.  
  10685. .windowtext
  10686.     dc.b    2,0,RP_JAM2,0
  10687.     dc.w    162,5
  10688.     dc.l    NULL
  10689.     dc.l    .text1
  10690.     dc.l    .it2
  10691. .it2
  10692.     dc.b    1,0,RP_JAM2,0
  10693.     dc.w    20,20
  10694.     dc.l    NULL
  10695.     dc.l    .text2
  10696.     dc.l    .it3
  10697. .it3
  10698.     dc.b    1,0,RP_JAM2,0
  10699.     dc.w    170,20
  10700.     dc.l    NULL
  10701.     dc.l    .text3
  10702.     dc.l    .it4
  10703. .it4
  10704.     dc.b    1,0,RP_JAM2,0
  10705.     dc.w    320,20
  10706.     dc.l    NULL
  10707.     dc.l    .text4
  10708.     dc.l    .it5
  10709. .it5
  10710.     dc.b    1,0,RP_JAM2,0
  10711.     dc.w    20,65
  10712.     dc.l    NULL
  10713.     dc.l    .text5
  10714.     dc.l    NULL
  10715.  
  10716. .text1    dc.b    "Print options",0
  10717. .text2    dc.b    "Left field",0
  10718. .text3    dc.b    "Middle field",0
  10719. .text4    dc.b    "Right field",0
  10720. .text5    dc.b    "Header style",0
  10721.  
  10722.     even
  10723.  
  10724.     incdir    ""
  10725.     include    Projekt:Textread/CASE/Textread.s
  10726.